Skip to content

Commit 0e0e6d5

Browse files
authored
Merge pull request #306 from habibasorour/issue_298_comment
Issue 298 fixes: comment added to 6.2
2 parents 08a99d5 + a34caa9 commit 0e0e6d5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

source/ch6_definingclasses.ptx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ public void setDenominator(Integer denominator) { // setter method
216216
<title>Writing a constructor</title>
217217

218218
<p>
219+
<idx>constructor</idx>
219220
Once you have identified the instance variables for your class the next thing to consider is the constructor.
220221
In Java, <term>constructors</term> have the same name as the class and are declared public.
221222
They are declared without a return type.
@@ -227,7 +228,7 @@ public void setDenominator(Integer denominator) { // setter method
227228
<program interactive="activecode" language="java">
228229
<code>
229230
public Fraction(Integer top, Integer bottom) {
230-
num = top;
231+
num = top; // notice the use of num instead of top
231232
den = bottom;
232233
}
233234
</code>
@@ -249,7 +250,7 @@ public Fraction(Integer top, Integer bottom) {
249250
<program interactive="activecode" language="java">
250251
<code>
251252
public Fraction(Integer num, Integer den) {
252-
this.num = num;
253+
this.num = num; // notice how we use this.num instead of num
253254
this.den = den;
254255
}
255256
</code>

0 commit comments

Comments
 (0)