From 965723778987bd20999c9cd1ef3d5fb9d81629e9 Mon Sep 17 00:00:00 2001
From: Habiba Sorour
Date: Sat, 1 Aug 2026 00:43:49 +0300
Subject: [PATCH 1/3] added listing tags
---
source/ch6_definingclasses.ptx | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/source/ch6_definingclasses.ptx b/source/ch6_definingclasses.ptx
index c1b2d6f..582ecd6 100644
--- a/source/ch6_definingclasses.ptx
+++ b/source/ch6_definingclasses.ptx
@@ -769,8 +769,8 @@ public void test(Number a, Number b) {
Here is an excerpt from the official documentation for the compareTo method as specified by the Comparable interface.
-
-
+
+
int compareTo(T o)
Compares this object with the specified object for order. Returns a
@@ -782,27 +782,29 @@ iff y.compareTo(x) throws an exception.)
...
+
To make our Fraction class Comparable we must modify the class declaration line as follows:
-
-
+
+
public class Fraction extends Number implements Comparable<Fraction> {
...
}
+
The specification Comparable<Fraction> makes it clear that Fraction is only comparable with another Fraction.
The compareTo method could be implemented as follows:
-
-
+
+
public int compareTo(Fraction other) {
Integer num1 = this.numerator * other.getDenominator();
@@ -811,8 +813,11 @@ public int compareTo(Fraction other) {
}
+
+
+
Static member variables
From 591a5fca21d0d0f7c02572fe9cfcf22f12874b3b Mon Sep 17 00:00:00 2001
From: Habiba Sorour
Date: Sat, 1 Aug 2026 00:46:09 +0300
Subject: [PATCH 2/3] fixed xml:id
---
source/ch6_definingclasses.ptx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source/ch6_definingclasses.ptx b/source/ch6_definingclasses.ptx
index 582ecd6..ac53379 100644
--- a/source/ch6_definingclasses.ptx
+++ b/source/ch6_definingclasses.ptx
@@ -803,7 +803,7 @@ public class Fraction extends Number implements Comparable<Fraction> {
The compareTo method could be implemented as follows:
-
+
public int compareTo(Fraction other) {
@@ -814,7 +814,7 @@ public int compareTo(Fraction other) {
-
+
From cfcccbda92d9a0ae38ab15b78e563b4463a43743 Mon Sep 17 00:00:00 2001
From: Habiba Sorour
Date: Sat, 1 Aug 2026 00:47:26 +0300
Subject: [PATCH 3/3] added listing to tags
---
source/ch6_definingclasses.ptx | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/source/ch6_definingclasses.ptx b/source/ch6_definingclasses.ptx
index ac53379..3450de8 100644
--- a/source/ch6_definingclasses.ptx
+++ b/source/ch6_definingclasses.ptx
@@ -766,7 +766,7 @@ public void test(Number a, Number b) {
The Comparable interface says that any object that claims to be Comparable must implement the compareTo method.
- Here is an excerpt from the official documentation for the compareTo method as specified by the Comparable interface.
+ Here is an excerpt from the official documentation for the compareTo method as specified by the Comparable interface. shows the excerpt.
@@ -785,7 +785,7 @@ iff y.compareTo(x) throws an exception.)
- To make our Fraction class Comparable we must modify the class declaration line as follows:
+ To make our Fraction class Comparable we must modify the class declaration line as shown in .
@@ -800,7 +800,7 @@ public class Fraction extends Number implements Comparable<Fraction> {
The specification Comparable<Fraction> makes it clear that Fraction is only comparable with another Fraction.
- The compareTo method could be implemented as follows:
+ The compareTo method could be implemented as shown in .