From d15068ba949ff3a1069495acdbea70b2ef8f60d4 Mon Sep 17 00:00:00 2001 From: Habiba Sorour Date: Fri, 31 Jul 2026 19:00:32 +0300 Subject: [PATCH 1/2] added comments to code --- 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 252ec9b..2d4a321 100644 --- a/source/ch6_definingclasses.ptx +++ b/source/ch6_definingclasses.ptx @@ -207,7 +207,7 @@ public void setDenominator(Integer denominator) { public Fraction(Integer top, Integer bottom) { - num = top; + num = top; // notice the use of num instead of top den = bottom; } @@ -228,7 +228,7 @@ public Fraction(Integer top, Integer bottom) { public Fraction(Integer num, Integer den) { - this.num = num; + this.num = num; // notice how we use this.num instead of num this.den = den; } From a34caa9d73799300fa3912ca38291c6db423208d Mon Sep 17 00:00:00 2001 From: Habiba Sorour Date: Fri, 31 Jul 2026 19:01:30 +0300 Subject: [PATCH 2/2] added an idx tag --- source/ch6_definingclasses.ptx | 1 + 1 file changed, 1 insertion(+) diff --git a/source/ch6_definingclasses.ptx b/source/ch6_definingclasses.ptx index 2d4a321..07b6931 100644 --- a/source/ch6_definingclasses.ptx +++ b/source/ch6_definingclasses.ptx @@ -196,6 +196,7 @@ public void setDenominator(Integer denominator) { Writing a constructor

+ constructor Once you have identified the instance variables for your class the next thing to consider is the constructor. In Java, constructors have the same name as the class and are declared public. They are declared without a return type.