diff --git a/source/ch6_definingclasses.ptx b/source/ch6_definingclasses.ptx
index c1b2d6f..aa0a311 100644
--- a/source/ch6_definingclasses.ptx
+++ b/source/ch6_definingclasses.ptx
@@ -559,7 +559,7 @@ Fraction@6ff3c5b5
public String toString() {
- return numerator.toString() + "/" + denominator.toString();
+ return numerator.toString() + "/" + denominator.toString(); // convert to a string
}
@@ -598,10 +598,10 @@ object1.equals(object2)
-public boolean equals(Fraction other) {
- Integer num1 = this.numerator * other.getDenominator();
- Integer num2 = this.denominator * other.getNumerator();
- if (num1 == num2)
+
+public boolean equals(Fraction other) { // a method to compare two fractions
+ Integer num1 = this.numerator * other.getDenominator(); Integer num2 = this.denominator * other.getNumerator();
+ if (num1 == num2) // if the numerators are equal in value, the fractions are equal
return true;
else
return false;
@@ -688,16 +688,16 @@ public class Fraction extends Number {
-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();
}
@@ -724,7 +724,7 @@ public long longValue() {
public void test(Number a, Number b) {
- a.add(b);
+ a.add(b); // this is a bad idea
}