Skip to content

Commit d83e30d

Browse files
committed
add listing to txt
1 parent e0796f8 commit d83e30d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

source/ch6_definingclasses.ptx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public Fraction(Integer num, Integer den) {
277277
However, if you reassign the parameter to a completely new object inside the method (e.g., <c>otherFrac = new Fraction(0,1);</c>), it would <em>not</em> affect the original variable outside the method, because you are only changing the local copy of the reference.
278278
</p>
279279
<p>
280-
Let&#x2019;s begin by implementing addition in Java:
280+
<xref ref="java-fraction-class-addition-initial" text="type-global"/> shows the first part of the Fraction class definition.
281281
</p>
282282

283283
<listing xml:id="java-fraction-class-addition-initial">
@@ -302,7 +302,7 @@ public Fraction add(Fraction otherFrac) {
302302
<p>
303303
Second, you will notice that the method makes use of the <c>this</c> variable.
304304
In this method, <c>this</c> is not necessary, because there is no ambiguity about the <c>numerator</c> and <c>denominator</c> variables.
305-
So the following version of the code is equivalent:
305+
<xref ref="java-fraction-class-addition-equivalent" text="type-global"/> is an equivalent version of <xref ref="java-fraction-class-addition-initial" text="type-global"/>.
306306
</p>
307307

308308
<listing xml:id="java-fraction-class-addition-equivalent">
@@ -364,7 +364,7 @@ public Fraction add(Fraction otherFrac) {
364364
To solve the problem of adding an <c>Integer</c> and a <c>Fraction</c> in Java we will overload both the constructor and the <c>add</c> method.
365365
We will overload the constructor so that if it only receives a single <c>Integer</c> it will convert the <c>Integer</c> into a <c>Fraction</c>.
366366
We will also overload the <c>add</c> method so that if it receives an <c>Integer</c> as a parameter it will first construct a <c>Fraction</c> from that integer and then add the two <c>Fractions</c> together.
367-
The new methods that accomplish this task are as follows:
367+
<xref ref="java-method-overloading" text="type-global"/> shows the new methods that accomplish this task.
368368
</p>
369369

370370
<listing xml:id="java-method-overloading">

0 commit comments

Comments
 (0)