Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions source/ch6_definingclasses.ptx
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ Fraction@6ff3c5b5
<program language="java">
<code>
public String toString() {
return numerator.toString() + "/" + denominator.toString();
return numerator.toString() + "/" + denominator.toString(); // convert to a string
}
</code>
</program>
Expand Down Expand Up @@ -703,16 +703,16 @@ public class Fraction extends Number { // fraction class is a child of Number
<listing xml:id="java-object-type-conversions">
<program language="java">
<code>
public double doubleValue() {
public double doubleValue() { // convert to a double
return numerator.doubleValue() / denominator.doubleValue();
}
public float floatValue() {
public float floatValue() { // convert to a float
return numerator.floatValue() / denominator.floatValue();
}
public int intValue() {
public int intValue() { // convert to an int
return numerator.intValue() / denominator.intValue();
}
public long longValue() {
public long longValue() { // convert to a long
return numerator.longValue() / denominator.longValue();
}
</code>
Expand Down Expand Up @@ -740,7 +740,7 @@ public long longValue() {
<program language="java">
<code>
public void test(Number a, Number b) {
a.add(b);
a.add(b); // this is a bad idea
}
</code>
</program>
Expand Down