Skip to content

Commit bd337ef

Browse files
committed
...
1 parent a7dcf5c commit bd337ef

17 files changed

+208
-28
lines changed

src/SUMMARY.md

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ snake
4343
2048
4444
colors
4545
battleship
46+
47+
CLI Hangman
48+
Tic Tac Toe AI
49+
4650
-->
4751

4852
# Modern Java
@@ -123,6 +127,16 @@ battleship
123127
- [Access Individual Characters](./strings/access_individual_characters.md)
124128
- [Challenges](./strings/challenges.md)
125129

130+
# Interactive Programs
131+
132+
- [Standard Input](./standard_input.md)
133+
- [Prompting](./standard_input/prompting.md)
134+
- [Interpreting Input](./standard_input/interpreting_input.md)
135+
- [Integers](./standard_input/integers.md)
136+
- [Floating Point Numbers](./standard_input/floating_point_numbers.md)
137+
- [Other Types](./standard_input/other_types.md)
138+
- [Challenges](./standard_input/challenges.md)
139+
126140
# Control Flow I
127141

128142
- [Branching Paths](./branching_paths.md)
@@ -153,6 +167,13 @@ battleship
153167
- [Iterate over a String](./loops/iterate_over_a_string.md)
154168
- [Challenges](./loops/challenges.md)
155169

170+
# Concepts
171+
- [Software is an Interdisciplinary Field]()
172+
173+
# Projects
174+
175+
- [Calorie Tracker]()
176+
156177
# Data Types II
157178

158179
- [Arrays](./arrays.md)
@@ -169,10 +190,6 @@ battleship
169190
- [Initialization with new](./arrays/initialization_with_new.md)
170191
- [Challenges](./arrays/challenges.md)
171192

172-
# Projects
173-
174-
- [The Boston Molasses Disaster Game]() <!-- Make sure they know it was because of deregulation -->
175-
176193
# Control Flow II
177194

178195
- [Loops II](./loops_ii.md)
@@ -197,6 +214,11 @@ battleship
197214
- [Drawing Isosceles Triangles](./loops_ii/drawing_isosceles_triangles.md)
198215
- [Challenges](./loops_ii/challenges.md)
199216

217+
# Projects
218+
219+
- [Calorie Tracker II]()
220+
- [Can you Build a Snowman?]()
221+
200222
# Code Structure
201223

202224
- [Methods](./methods.md)
@@ -229,6 +251,7 @@ battleship
229251
# Projects
230252

231253
- [Tic-Tac-Toe]()
254+
- [Chicken Nugget Numbers]()
232255

233256
# Data Types III
234257

@@ -258,6 +281,7 @@ battleship
258281
<!-- https://michaelxing.com/UltimateTTT/v3/ -->
259282
- [Ultimate Tic-Tac-Toe]()
260283

284+
261285
# Code Structure II
262286

263287
- [Classes](./classes.md)
@@ -285,6 +309,10 @@ battleship
285309
- [Clarity](./instance_methods/clarity.md)
286310
- [Challenges](./instance_methods/challenges.md)
287311

312+
# Projects II
313+
314+
- [Monte Carlo Sampling]()
315+
288316
# Data Types IV
289317

290318
- [Enums](./enums.md)
@@ -352,13 +380,13 @@ battleship
352380

353381
# Interactive Programs
354382

355-
- [Standard Input](./standard_input.md)
356-
- [Prompting](./standard_input/prompting.md)
357-
- [Interpreting Input](./standard_input/interpreting_input.md)
358-
- [Reprompting](./standard_input/reprompting.md)
359-
- [Leniency](./standard_input/leniency.md)
360-
- [Delayed Assignment](./standard_input/delayed_assignment.md)
361-
- [Transporting Data](./standard_input/transporting_data.md)
383+
- [Standard Input II](./standard_input_ii.md)
384+
- [Prompting](./standard_input_ii/prompting.md)
385+
- [Interpreting Input](./standard_input_ii/interpreting_input.md)
386+
- [Reprompting](./standard_input_ii/reprompting.md)
387+
- [Leniency](./standard_input_ii/leniency.md)
388+
- [Delayed Assignment](./standard_input_ii/delayed_assignment.md)
389+
- [Transporting Data](./standard_input_ii/transporting_data.md)
362390

363391
# The Computing Environment
364392

@@ -451,7 +479,6 @@ battleship
451479
- [Accessing Arguments](./command_line_arguments/accessing_arguments.md)
452480
- [Conventions](./command_line_arguments/conventions.md)
453481

454-
455482
# Code Structure V
456483

457484
- [Inner Classes](./inner_classes.md)
@@ -514,7 +541,14 @@ battleship
514541
- [Challenges](./files/challenges.md)
515542

516543

544+
# Projects
545+
546+
<!-- read and write some journal entries -->
547+
- [Journal Entries]()
517548

549+
<!-- Make a picture in PPM format -->
550+
- [Draw a Picture]()
551+
518552
<!--
519553
# Data Structures & Algorithms II
520554
@@ -722,6 +756,11 @@ Make them do one. -->
722756
- [long](./niche_numerics/long.md)
723757
- [Unsigned Operations](./niche_numerics/unsigned_operations.md)
724758
- [float](./niche_numerics/float.md)
759+
760+
# Projects
761+
762+
<!-- Make a WAV file that plays hot cross buns -->
763+
- [Hot Cross Buns]()
725764

726765
# Code Structure VIII
727766

src/standard_input/booleans.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Booleans

src/standard_input/challenges.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Challenges
2+
3+
Remember the rules for this are
4+
5+
- Try to use only the information given up to this point in this book.
6+
- Try not to give up until you've given it a solid attempt
7+
8+
## Challenge 1
9+
10+
Write a program that asks a person for their name and then says
11+
"Hello \<their name\>" back to them.
12+
13+
```java,no_run
14+
void main() {
15+
// 1. Call IO.readln to get their name
16+
// 2. Call IO.print/IO.println to say hello to them
17+
}
18+
```
19+
20+
## Challenge 2
21+
22+
Write a program that asks a person their age and tells them
23+
what age they will be this time next year.
24+
25+
```java,no_run
26+
void main() {
27+
// 1. Call IO.readln to get their age
28+
// 2. Interpret their age as an int
29+
// 3. Add one to that age
30+
// 2. Call IO.print/IO.println to say what age they will be next year
31+
}
32+
```
33+
34+
## Challenge 3
35+
36+
Write a program that asks a person for two floating point numbers and tells them
37+
what the sum of those two numbers is
38+
39+
```java,no_run
40+
void main() {
41+
// 1. Call IO.readln to get the first number
42+
// 2. Interpret that first number as a double
43+
// 3. Call IO.readln to get the second number
44+
// 4. Interpret that second number as a double
45+
// 5. Add the two numbers together
46+
// 6. Call IO.print/IO.println to say what the sum is
47+
}
48+
```
49+
50+
## Challenge 4
51+
52+
["Mad Libs"](https://en.wikipedia.org/wiki/Mad_Libs) are a word game where you ask people for nouns, verbs, and adjectives absent any context
53+
and then fill them in to a template.
54+
55+
For example
56+
57+
```
58+
I saw a <noun> today and <past tense verb>.
59+
Unfortunately the <noun> stopped me at the <noun>.
60+
```
61+
62+
Can become
63+
64+
```
65+
I saw a dog today and flew.
66+
Unfortunately the clown stopped me at the elephant.
67+
```
68+
69+
Make a program that asks a user for some nouns, verbs, etc. and produces
70+
a Mad Lib using those words.

src/standard_input/characters.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Characters
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Floating Point Numbers
2+
3+
If you expect someone to type a floating point value you can turn the `String`
4+
you get from `IO.readln` into a `double` using `Double.parseDouble`.
5+
6+
```java,do_not_run
7+
void main() {
8+
String gpaString = IO.readln("What is your GPA? ");
9+
double gpa = Double.parseDouble(gpaString);
10+
IO.println("You are " + age + " years old!");
11+
}
12+
```
13+
14+
So long as they type something which can be interpreted as a `double` (like `123` or `14.5`)
15+
you will get a value for the `double` variable. Otherwise the program will crash.

src/standard_input/integers.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Integers
2+
3+
If you expect someone to type an integer value you can turn the `String`
4+
you get from `IO.readln` into an `int` using `Integer.parseInt`.
5+
6+
```java,do_not_run
7+
void main() {
8+
String ageString = IO.readln("How old are you? ");
9+
int age = Integer.parseInt(ageString);
10+
IO.println("You are " + age + " years old!");
11+
}
12+
```
13+
14+
So long as they type something which can be interpreted as an `int` (like `123`)
15+
you will get a value for the `int` variable. Otherwise
16+
the program will crash.

src/standard_input/interpreting_input.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,7 @@
33
When you call `IO.readln` the human on the other side can type whatever they want.
44

55
This means that, depending on the question you asked, you might need to interpret
6-
what they typed as something other than a generic `String`.
6+
what they typed as something other than a `String`.
77

8-
In its most basic form this will look like seeing if one `String` equals another `String`.
9-
10-
```java,no_run
11-
void main() {
12-
while (true) {
13-
String shouldExit = IO.readln("Exit the program? (y/n)");
14-
if (shouldExit.equals("y")) {
15-
break;
16-
}
17-
}
18-
}
19-
```
8+
The way to do this differs depending on what type you want, but for at least the types we covered so far
9+
there is a basic-enough process.

src/standard_input/other_types.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Other Types
2+
3+
Just as you can turn a `String` into an `int` using `Integer.parseInt` and you can
4+
turn a `String` into a `double` using `Double.parseDouble`, you can use `Boolean.parseBoolean` to turn a `String` into a `boolean`.
5+
6+
```java,do_not_run
7+
void main() {
8+
String happyString = IO.readln("Are you happy? ");
9+
boolean happy = Boolean.parseBoolean(happyString);
10+
IO.println("You are happy? " + happy);
11+
}
12+
```
13+
14+
But lest you become too comfortable, know that there is no `Character.parseCharacter` to turn a `String` into a character.
15+
It is not always going to be the case that there is just one way to convert a `String` to any given type.
16+
17+
```java,do_not_run,panics
18+
void main() {
19+
String gradeString = IO.readln("What is your letter grade? ");
20+
// Does not exist!
21+
char grade = Character.parseCharacter(gradeString);
22+
IO.println("You have a " + grade + " in the class.");
23+
}
24+
```

src/standard_input/prompting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# input
1+
# Prompting
22

33
To prompt a user for information you use the `IO.readln` function.
44

@@ -15,4 +15,4 @@ void main() {
1515
}
1616
```
1717

18-
`readln` stands for "read line." It reads the next line a person types.
18+
`readln` stands for "read line." It reads the next line a person types on "standard input".

src/standard_input/strings.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Strings
2+

0 commit comments

Comments
 (0)