Skip to content

Commit 1b57b17

Browse files
authored
Merge branch 'master' into ch8.3new
2 parents eaa69a4 + b606e0d commit 1b57b17

5 files changed

Lines changed: 32 additions & 21 deletions

File tree

source/ch2_firstjavaprogram.ptx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<title>Classes and Objects</title>
99

1010
<p>
11-
<idx>Object-Oriented Programming (OOP)</idx>
12-
Depending on how deep your knowledge of Python and programming in general is, you may or may not be familiar with classes and objects. These two important <term>Object-Oriented Programming (OOP)</term> concepts will briefly be discussed. If you already have a good understanding of classes and objects in Python, this section may be skipped.
11+
<idx>object-oriented programming</idx> <idx>OOP</idx>
12+
Depending on how deep your knowledge of Python and programming in general is, you may or may not be familiar with classes and objects. These two important <term>Object-Oriented Programming</term> (<term>OOP</term>) concepts will briefly be discussed. If you already have a good understanding of classes and objects in Python, this section may be skipped.
1313
</p>
1414

1515
<p>

source/ch3_javadatatypes.ptx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -728,18 +728,28 @@ main()
728728
This program reads the file <c>alice30.txt</c> (which follows), and it then splits it into a list of words. Next it creates a dictionary called <c>count</c> which maps each word to the number of times that word occurs in the text. Finally, it prints out the words in alphabetical order along with their frequency.
729729
</p>
730730

731-
<datafile label="datafile-alice1" filename="alice30.txt" editable="no" cols="30" rows="15"><pre>
732-
Down, down, down. Would the fall NEVER come to an end!
733-
'I wonder how many miles I've fallen by this time?' she said aloud. 'I must
734-
be getting somewhere near the centre of the earth.
735-
Let me see: that would be four thousand miles down, I think--'
736-
(for, you see, Alice had learnt several things of this sort in her lessons
737-
in the schoolroom, and though this was not a VERY good opportunity for
738-
showing off her knowledge, as there was no one to listen to her, still it
739-
was good practice to say it over) '--yes, that's about the right distance
740-
--but then I wonder what Latitude or Longitude I've got to?'
741-
(Alice had no idea what Latitude was, or Longitude either,
742-
but thought they were nice grand words to say.) </pre></datafile>
731+
<datafile label="datafile-alice1" filename="alice30.txt" editable="no" cols="30" rows="15">
732+
<pre>
733+
Down, down, down. Would the fall NEVER
734+
come to an end! 'I wonder how many
735+
miles I've fallen by this time?' she
736+
said aloud. 'I must be getting somewhere
737+
near the centre of the earth. Let me see:
738+
that would be four thousand miles down,
739+
I think--' (for, you see, Alice had
740+
learnt several things of this sort in
741+
her lessons in the schoolroom, and though
742+
this was not a VERY good opportunity for
743+
showing off her knowledge, as there was no
744+
one to listen to her, still it was good
745+
practice to say it over) '--yes, that's
746+
about the right distance--but then I
747+
wonder what Latitude or Longitude I've got
748+
to?' (Alice had no idea what Latitude was,
749+
or Longitude either, but thought they were
750+
nice grand words to say.)
751+
</pre>
752+
</datafile>
743753
<p>
744754
Notice that the structure of the program is very similar to the numeric histogram program.
745755
</p>

source/ch4_conditionals.ptx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ The <c>switch</c> statement is not used very often, and we recommend you do not
389389
<section xml:id="boolean-operators">
390390
<title>Boolean Operators</title>
391391

392-
<p><idx>Boolean operators</idx>
393-
The conditionals used in the if statement can be Boolean variables, simple comparisons, and compound Boolean expressions.
392+
<p><idx>Boolean operators</idx> <idx>simple comparisons</idx> <idx>compound Boolean expressions</idx>
393+
The conditionals used in the if statement can be <term>Boolean variables</term>, <term>simple comparisons</term>, and <term>compound Boolean expressions</term>.
394394
</p>
395395

396396
<p><idx>ternary operator</idx>
@@ -408,7 +408,7 @@ of an assignment statement. The following table summarizes how this works:
408408
</row>
409409
<row>
410410
<cell><c>condition</c></cell>
411-
<cell>The Boolean expression that is evaluated (e.g., <c>a % 2 == 0</c>).</cell>
411+
<cell>The <c>boolean</c> expression that is evaluated (e.g., <c>a % 2 == 0</c>).</cell>
412412
</row>
413413
<row>
414414
<cell><c>?</c></cell>

source/ch5_loopsanditeration.ptx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ public class DoWhileExample {
321321
</choice>
322322
</choices>
323323
</exercise>
324-
325324
</reading-questions>
326325
</section>
327326
</chapter>

source/ch8_filehandling.ptx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
<section xml:id="creating-files">
8686
<title>Creating Files</title>
8787

88+
8889
<p>
8990
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>.
9091
</p>
@@ -111,8 +112,9 @@
111112
</p>
112113
</note>
113114

115+
114116
<p>
115-
Now that we have created a new <c>File</c> object, we can create a file using the <c>createNewFile()</c> method from the <c>File</c> class. While the previous line of code creates an object within the program for the file, this method actually does the work of creating a file and saving it in the current working directory. This method returns a boolean value. If the method returns <c>true</c>, the file was successfully created. If the method returns <c>false</c>, there is already a file using the chosen file name. We can use this method's possible return values in tandem with an try/catch structure to determine if the file was created, or catch the error if a file with that file name already exists in the directory.
117+
Now let's learn how to make a file in Java. In Python. files can be made using the <c>open()</c> function on a file path that doesn't exist yet. Similarly, in Java you create a file by using the <c>createNewFile()</c> method on a <c>File</c> object. This method actually does the work of creating a file and saving it in the current working directory, and returns a boolean value of either true or false if the file is successfully created. We can use this method's possible return values in tandem with an try/catch structure to determine if the file was created, or catch the error if a file with that file name already exists in the directory.
116118
</p>
117119

118120
<p>
@@ -408,15 +410,15 @@
408410
</note>
409411

410412
<p>
411-
Speaking of overwriting data, what if we want to append text to the end of any text already in <c>myfile.txt</c>? To accomplish this, we can pass a boolean argument along with the file name when creating a new data argument:
413+
Speaking of overwriting data, what if we want to append text to the end of any text already in <c>myfile.txt</c>? To accomplish this, we can pass a <c>boolean</c> argument along with the file name when creating a new data argument:
412414
</p>
413415

414416
<pre>
415417
FileWriter myWriter = new FileWriter("myfile.txt", true); // true enables append mode
416418
</pre>
417419

418420
<p>
419-
Now, when we use <c>write()</c> method like before, the text will be appended if there is already text in the document. If we were to update our code to include the boolean argument:
421+
Now, when we use <c>write()</c> method like before, the text will be appended if there is already text in the document. If we were to update our code to include the <c>boolean</c> argument:
420422
</p>
421423
<datafile label="my-file-8-4-6" filename="myfile.txt" xml:id= "my-file-8-4-6" editable="yes">
422424
<pre>

0 commit comments

Comments
 (0)