From 1eb27de8c3fde657aea5376c57d5b84bccab6947 Mon Sep 17 00:00:00 2001
From: Habiba Sorour
Date: Fri, 31 Jul 2026 18:47:46 +0300
Subject: [PATCH 1/2] added listing tags
---
source/ch6_definingclasses.ptx | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/source/ch6_definingclasses.ptx b/source/ch6_definingclasses.ptx
index 252ec9b..e5012be 100644
--- a/source/ch6_definingclasses.ptx
+++ b/source/ch6_definingclasses.ptx
@@ -203,8 +203,8 @@ public void setDenominator(Integer denominator) {
Our constructor will take two parameters: the numerator and the denominator.
-
-
+
+
public Fraction(Integer top, Integer bottom) {
num = top;
@@ -212,6 +212,7 @@ public Fraction(Integer top, Integer bottom) {
}
+
this
@@ -224,8 +225,8 @@ public Fraction(Integer top, Integer bottom) {
For example this alternate definition of the the Fraction constructor uses this to differentiate between parameters and instance variables.
-
-
+
+
public Fraction(Integer num, Integer den) {
this.num = num;
@@ -233,6 +234,7 @@ public Fraction(Integer num, Integer den) {
}
+
From 7c86b21541b43c63e5da2825329df06d14b88241 Mon Sep 17 00:00:00 2001
From: Habiba Sorour
Date: Fri, 31 Jul 2026 18:52:05 +0300
Subject: [PATCH 2/2] added listing to txt
---
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 e5012be..185851a 100644
--- a/source/ch6_definingclasses.ptx
+++ b/source/ch6_definingclasses.ptx
@@ -200,7 +200,7 @@ public void setDenominator(Integer denominator) {
In Java, constructors have the same name as the class and are declared public.
They are declared without a return type.
So any method that is named the same as the class and has no return type is a constructor.
- Our constructor will take two parameters: the numerator and the denominator.
+ Our constructor will take two parameters: the numerator and the denominator. shows the constructor for the Fraction class.
@@ -222,7 +222,7 @@ public Fraction(Integer top, Integer bottom) {
This allows the Java compiler to do the work of dereferencing the current Java object.
Java does provide a special variable called this that works like the self variable.
In Java, this is typically only used when it is needed to differentiate between a parameter or local variable and an instance variable.
- For example this alternate definition of the the Fraction constructor uses this to differentiate between parameters and instance variables.
+ For example, shows an alternate definition of the the Fraction constructor that uses this to differentiate between parameters and instance variables.