Skip to content

Commit 43d04f8

Browse files
authored
Merge pull request #324 from DieuMerci225/chapter6listing
Added the listing tag to the chapter 6.7.1, I also renamed the XMLID to a more meaningful name,added pragraph for the listing
2 parents e296242 + e1d138d commit 43d04f8

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
@@ -902,8 +902,12 @@ public class Student {
902902
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>.
903903
</p>
904904

905+
<p>
906+
<xref ref="java-gcd-helper-method" text="type-global"/> shows the implementation of the static gcd helper method in Java.
907+
</p>
905908

906-
<program xml:id="java-gcd" language="java">
909+
<listing xml:id="java-gcd-helper-method">
910+
<program interactive="activecode" language="java">
907911
<code>
908912
private static Integer gcd(Integer m, Integer n) {
909913
while (m % n != 0) {
@@ -916,6 +920,7 @@ private static Integer gcd(Integer m, Integer n) {
916920
}
917921
</code>
918922
</program>
923+
</listing>
919924
</section>
920925

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

0 commit comments

Comments
 (0)