Skip to content

Commit e1d138d

Browse files
nshizirungudieumerci@gmail.comnshizirungudieumerci@gmail.com
authored andcommitted
Added the listing tag to the chapter 6.7.1, I also renamed the XMLID to a more meaningful name, and added a paragrph describing the listing
1 parent d2798a2 commit e1d138d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

source/ch6_definingclasses.ptx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,8 +879,12 @@ public class Student {
879879
We have already discussed the most common static method of all, <c>main</c>. However in our <c>Fraction</c> class we also implemented a method to calculate the greatest common divisor for two fractions (<c>gdc</c>). There is no reason for this method to be a member method since it takes two <c>Integer</c> values as its parameters. Therefore we declare the method to be a static method of the class. Furthermore, since we are only going to use this <c>gcd</c> method for our own purposes we can make it <c>private</c>.
880880
</p>
881881

882+
<p>
883+
<xref ref="java-gcd-helper-method" text="type-global"/> shows the implementation of the static gcd helper method in Java.
884+
</p>
882885

883-
<program xml:id="java-gcd" language="java">
886+
<listing xml:id="java-gcd-helper-method">
887+
<program interactive="activecode" language="java">
884888
<code>
885889
private static Integer gcd(Integer m, Integer n) {
886890
while (m % n != 0) {
@@ -893,6 +897,7 @@ private static Integer gcd(Integer m, Integer n) {
893897
}
894898
</code>
895899
</program>
900+
</listing>
896901
</section>
897902

898903
<section xml:id="full-implementation-of-the-fraction-class">

0 commit comments

Comments
 (0)