Skip to content

Commit d01bc7e

Browse files
authored
Merge pull request #343 from habibasorour/issue_333_listing
Issue 332 fixed: 8.2 listing
2 parents 35cc975 + b2ca8bc commit d01bc7e

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

source/ch7_recursion.ptx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ def main():
238238
main()
239239
</code>
240240
</program>
241+
</listing>
241242

242243
<p><idx>separation of concerns</idx>
243244
The key insight here is called the <term>separation of concerns</term>. The public <c>sum_array</c> method provides a user-friendly interface—callers just pass an array and get the sum. Users don't need to know about indexes or how the recursion works internally. The private <c>_sum_helper</c> method handles the recursive logic with the extra parameter needed to track progress through the array.

source/ch8_filehandling.ptx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@
7373

7474

7575
<p>
76-
We will now create a <c>File</c> object. It is important to create a meaningful name for the <c>File</c> object. We will call ours <c>myFile</c>, and we will call our class <c>CreateFileObject</c>.
76+
We will now create a <c>File</c> object. It is important to create a meaningful name for the <c>File</c> object. We will call ours <c>myFile</c>, and we will call our class <c>CreateFileObject</c>. <xref ref="create-file-object-java" text="type-global"/> shows the code to create a <c>File</c> object in Java.
7777
</p>
78-
79-
<program xml:id="create-file-object-java" interactive="activecode" language="java" add-files="myfile-created">
78+
<listing xml:id="create-file-object-java">
79+
<program interactive="activecode" language="java" add-files="myfile-created">
8080
<code>
8181
import java.io.File;
8282

@@ -90,6 +90,7 @@ public class CreateFile {
9090
}
9191
</code>
9292
</program>
93+
</listing>
9394

9495
<note>
9596
<p>
@@ -103,10 +104,10 @@ public class CreateFile {
103104
</p>
104105

105106
<p>
106-
First, lets look at the equivalent Python code:
107+
<xref ref="create-file-python" text="type-global"/> shows the equivalent code to create a file in Python.
107108
</p>
108-
109-
<program xml:id="create-file-python" interactive="activecode" language="python">
109+
<listing xml:id="create-file-python">
110+
<program interactive="activecode" language="python">
110111
<code>
111112
filename = "newfile.txt"
112113
print("Attempting to write to '" + filename + "' using 'w' mode...")
@@ -120,12 +121,13 @@ public class CreateFile {
120121

121122
</code>
122123
</program>
124+
</listing>
123125

124126
<p>
125-
Now, let's look at Java code that accomplishes the same task:
127+
<xref ref="create-file-java" text="type-global"/> shows the equivalent code to create a file in Java.
126128
</p>
127-
128-
<program xml:id="create-file-java" interactive="activecode" language="java">
129+
<listing xml:id="create-file-java">
130+
<program interactive="activecode" language="java">
129131
<code>
130132
import java.io.File;
131133
import java.io.IOException;
@@ -148,6 +150,7 @@ public class CreateFile {
148150
}
149151
</code>
150152
</program>
153+
</listing>
151154

152155
<note>
153156
<p>

0 commit comments

Comments
 (0)