Skip to content

Commit 7044540

Browse files
committed
added comments
1 parent d2798a2 commit 7044540

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

source/ch6_definingclasses.ptx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ public String toString() {
576576

577577
<program xml:id="java-class-equalqqual" language="java">
578578
<code>
579-
object1 == object2
579+
object1 == object2 // this checks to see if the two objects are the same object in memory
580580
</code>
581581
</program>
582582

@@ -587,7 +587,7 @@ object1 == object2
587587

588588
<program xml:id="java-class-dot-equals" language="java">
589589
<code>
590-
object1.equals(object2)
590+
object1.equals(object2) // this checks to see if the two objects are equal by looking at their instance variables
591591
</code>
592592
</program>
593593

@@ -598,7 +598,7 @@ object1.equals(object2)
598598

599599
<program xml:id="java-fraction-equals" language="java">
600600
<code>
601-
public boolean equals(Fraction other) {
601+
public boolean equals(Fraction other) { // check if this fraction is equal to another fraction
602602
Integer num1 = this.numerator * other.getDenominator();
603603
Integer num2 = this.denominator * other.getNumerator();
604604
if (num1 == num2)
@@ -637,7 +637,7 @@ public boolean equals(Fraction other) {
637637

638638
<program xml:id="pjava-extends" language="java">
639639
<code>
640-
public class Fraction extends Number {
640+
public class Fraction extends Number { // fraction class is a child of Number
641641
...
642642
}
643643
</code>
@@ -790,7 +790,7 @@ iff y.compareTo(x) throws an exception.)
790790

791791
<program xml:id="java-make-comparable" language="java">
792792
<code>
793-
public class Fraction extends Number implements Comparable&lt;Fraction&gt; {
793+
public class Fraction extends Number implements Comparable&lt;Fraction&gt; { // fraction class is a child of Number and implements the Comparable interface
794794
...
795795
}
796796
</code>
@@ -804,7 +804,7 @@ public class Fraction extends Number implements Comparable&lt;Fraction&gt; {
804804

805805
<program xml:id="java-comparable2" language="java">
806806
<code>
807-
public int compareTo(Fraction other) {
807+
public int compareTo(Fraction other) { // compare this fraction with another fraction
808808
Integer num1 = this.numerator * other.getDenominator();
809809
Integer num2 = this.denominator * other.getNumerator();
810810
return num1 - num2;

0 commit comments

Comments
 (0)