diff --git a/source/ch6_definingclasses.ptx b/source/ch6_definingclasses.ptx index 252ec9b..185851a 100644 --- a/source/ch6_definingclasses.ptx +++ b/source/ch6_definingclasses.ptx @@ -200,11 +200,11 @@ 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.

- - + + public Fraction(Integer top, Integer bottom) { num = top; @@ -212,6 +212,7 @@ public Fraction(Integer top, Integer bottom) { } +

this @@ -221,11 +222,11 @@ 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.

- - + + public Fraction(Integer num, Integer den) { this.num = num; @@ -233,6 +234,7 @@ public Fraction(Integer num, Integer den) { } +