You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/ch6_definingclasses.ptx
+11-12Lines changed: 11 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -462,7 +462,7 @@ public class Fraction {
462
462
463
463
<introduction>
464
464
<p>
465
-
If you ran the program above you probably noticed that the output is not very satisfying. Chances are your output looked something like this:
465
+
If you ran the program above you probably noticed that the output is not very satisfying. Chances are your output looked something like <xrefref="java-no-friendly-output"text="type-global"/>.
466
466
</p>
467
467
468
468
<listingxml:id="java-no-friendly-output">
@@ -552,8 +552,7 @@ Fraction@6ff3c5b5
552
552
553
553
<p>
554
554
We are not interested in most of the methods on that list, and many Java programmers live happy and productive lives without knowing much about most of the methods on that list.
555
-
However, to make our output nicer we will implement the <c>toString</c> method for the <c>Fraction</c> class.
556
-
A simple version of the method is provided below.
555
+
However, to make our output nicer we will implement the <c>toString</c> method for the <c>Fraction</c> class. <xrefref="java-tostring"text="type-global"/> shows a simple version of the method.
557
556
</p>
558
557
559
558
<listingxml:id="java-tostring">
@@ -576,28 +575,28 @@ public String toString() {
576
575
Therefore once you write your own <c>equals</c> method:
577
576
</p>
578
577
579
-
<listingxml:id="java-class-equalequal">
580
-
<programlanguage="java">
578
+
<listingxml:id="java-class-equal-equal">
579
+
<program>
581
580
<code>
582
581
object1 == object2
583
582
</code>
584
583
</program>
585
584
</listing>
586
585
587
586
<p>
588
-
is NOT the same as:
587
+
<xrefref="java-class-equal-equal"text="type-global"/> is NOT the same as <xrefref="java-class-dot-equals"text="type-global"/>.
589
588
</p>
590
589
591
590
<listingxml:id="java-class-dot-equals">
592
-
<programlanguage="java">
591
+
<program>
593
592
<code>
594
593
object1.equals(object2)
595
594
</code>
596
595
</program>
597
596
</listing>
598
597
599
598
<p>
600
-
Here is an <c>equals</c> method for the <c>Fraction</c> class:
599
+
<xrefref="java-fraction-equals"text="type-global"/> is an <c>equals</c> method for the <c>Fraction</c> class.
601
600
</p>
602
601
603
602
<listingxml:id="java-fraction-equals">
@@ -637,11 +636,11 @@ public boolean equals(Fraction other) {
637
636
</p>
638
637
639
638
<p>
640
-
Here is code that makes the <c>Fraction</c> class a child of <c>Number</c>:
639
+
<xrefref="java-class-extends"text="type-global"/> makes the <c>Fraction</c> class a child of <c>Number</c>.
641
640
</p>
642
641
643
642
<listingxml:id="java-class-extends">
644
-
<programlanguage="java">
643
+
<program>
645
644
<code>
646
645
public class Fraction extends Number {
647
646
...
@@ -689,7 +688,7 @@ public class Fraction extends Number {
689
688
</p>
690
689
691
690
<p>
692
-
This really isn’t much work for us to implement these methods, as all we have to do is some type conversion and some division:
691
+
This really isn’t much work for us to implement these methods, as all we have to do is some type conversion and some division as shown in <xrefref="java-object-type-conversions"text="type-global"/>.
693
692
</p>
694
693
695
694
<listingxml:id="java-object-type-conversions">
@@ -725,7 +724,7 @@ public long longValue() {
725
724
</p>
726
725
727
726
<p>
728
-
Suppose you try to define a method as follows:
727
+
Suppose you try to define a method as <xrefref="java-ugly-add-method"text="type-global"/>.
0 commit comments