Skip to content

Commit 00a013c

Browse files
committed
add listing to text
1 parent e371066 commit 00a013c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

source/ch6_definingclasses.ptx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
</p>
6363

6464
<p>
65-
Here is a mostly complete implementation of a Fraction class in Python that we will refer to throughout this section:
65+
<xref ref="python-fracion-class1" text="type-global"/> is a mostly complete implementation of a Fraction class in Python that we will refer to throughout this section.
6666
</p>
6767

6868
<listing xml:id="python-fracion-class1">
@@ -134,7 +134,7 @@
134134
</p>
135135

136136
<p>
137-
The declarations of instance variables can come at the beginning of the class definition or the end. Cay Horstman, author of <url href="https://horstmann.com/corejava/index.html" visual="https://horstmann.com/corejava/index.html">the &#x201C;Core Java&#x201D; books</url> puts the declarations at the end of the class. I like them at the very beginning so you see the variables that are declared before you begin looking at the code that uses them. With that in mind the first part of the Fraction class definition is as follows:
137+
The declarations of instance variables can come at the beginning of the class definition or the end. Cay Horstman, author of <url href="https://horstmann.com/corejava/index.html" visual="https://horstmann.com/corejava/index.html">the &#x201C;Core Java&#x201D; books</url> puts the declarations at the end of the class. I like them at the very beginning so you see the variables that are declared before you begin looking at the code that uses them. With that in mind <xref ref="java-fraction-class1" text="type-global"/> shows the first part of the Fraction class definition.
138138
</p>
139139

140140
<listing xml:id="java-fraction-class1">
@@ -150,7 +150,7 @@
150150

151151
<p>
152152
Notice that we have declared the numerator and denominator to be <term>private</term>.
153-
This means that the compiler will generate an error if another method tries to write code like the following:
153+
This means that the compiler will generate an error if another method tries to write code like <xref ref="java-private" text="type-global"/>.
154154
</p>
155155

156156
<listing xml:id="java-private">
@@ -167,7 +167,7 @@
167167
<idx>setter method</idx>
168168
Direct access to instance variables is not allowed in Java.
169169
Therefore if we legitimately want to be able to access information such as the numerator or the denominator for a particular fraction we must have a <term>getter method</term> that returns the needed value.
170-
Hence, it is a very common programming practice to both provide <term>getter methods</term> and <term>setter methods</term> when needed for instance variables in Java.
170+
Hence, it is a very common programming practice to both provide <term>getter methods</term> and <term>setter methods</term> when needed for instance variables in Java. <xref ref="java-getter-and-setter" text="type-global"/> shows how the getter and setter methods are written.
171171
</p>
172172

173173
<listing xml:id="java-getter-and-setter">

0 commit comments

Comments
 (0)