Skip to content

Commit 984b03b

Browse files
authored
Merge pull request #321 from habibasorour/issue_313_comment
Issue 313 fiixed: added comments in 6.5
2 parents b5d79a1 + 7044540 commit 984b03b

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
@@ -587,7 +587,7 @@ public String toString() {
587587
<listing xml:id="java-class-equal-equal">
588588
<program>
589589
<code>
590-
object1 == object2
590+
object1 == object2 // this checks to see if the two objects are the same object in memory
591591
</code>
592592
</program>
593593
</listing>
@@ -599,7 +599,7 @@ object1 == object2
599599
<listing xml:id="java-class-dot-equals">
600600
<program>
601601
<code>
602-
object1.equals(object2)
602+
object1.equals(object2) // this checks to see if the two objects are equal by looking at their instance variables
603603
</code>
604604
</program>
605605
</listing>
@@ -611,7 +611,7 @@ object1.equals(object2)
611611
<listing xml:id="java-fraction-equals">
612612
<program language="java">
613613
<code>
614-
public boolean equals(Fraction other) {
614+
public boolean equals(Fraction other) { // check if this fraction is equal to another fraction
615615
Integer num1 = this.numerator * other.getDenominator();
616616
Integer num2 = this.denominator * other.getNumerator();
617617
if (num1 == num2)
@@ -651,7 +651,7 @@ public boolean equals(Fraction other) {
651651
<listing xml:id="java-class-extends">
652652
<program>
653653
<code>
654-
public class Fraction extends Number {
654+
public class Fraction extends Number { // fraction class is a child of Number
655655
...
656656
}
657657
</code>
@@ -806,7 +806,7 @@ iff y.compareTo(x) throws an exception.)
806806

807807
<program xml:id="java-make-comparable" language="java">
808808
<code>
809-
public class Fraction extends Number implements Comparable&lt;Fraction&gt; {
809+
public class Fraction extends Number implements Comparable&lt;Fraction&gt; { // fraction class is a child of Number and implements the Comparable interface
810810
...
811811
}
812812
</code>
@@ -820,7 +820,7 @@ public class Fraction extends Number implements Comparable&lt;Fraction&gt; {
820820

821821
<program xml:id="java-comparable2" language="java">
822822
<code>
823-
public int compareTo(Fraction other) {
823+
public int compareTo(Fraction other) { // compare this fraction with another fraction
824824
Integer num1 = this.numerator * other.getDenominator();
825825
Integer num2 = this.denominator * other.getNumerator();
826826
return num1 - num2;

0 commit comments

Comments
 (0)