Skip to content

Commit b457d9a

Browse files
committed
...
1 parent 50a32b0 commit b457d9a

File tree

11 files changed

+107
-7
lines changed

11 files changed

+107
-7
lines changed

src/SUMMARY.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,9 @@ BFS
375375
- [ints](./switch/ints.md)
376376
- [Enums](./switch/enums.md)
377377
- [Omitted Default](./switch/omitted_default.md)
378-
- [Exhaustiveness](./switch/exhaustiveness.md)
379378
- [Combining Cases](./switch/combining_cases.md)
380379
- [null](./switch/null.md)
380+
- [Exhaustiveness](./switch/exhaustiveness.md)
381381
- [Challenges](./switch/challenges.md)
382382

383383

@@ -460,11 +460,13 @@ BFS
460460
- [Exception](./exceptions_ii/exception.md)
461461
- [RuntimeException](./exceptions_ii/runtime_exception.md)
462462
- [main](./exceptions_ii/main.md)
463+
- [Challenges](./exceptions_ii/challenges.md)
463464
- [Switch II](./switch_ii.md)
464465
- [Yield](./switch_ii/yield.md)
465466
- [Omitted Yield](./switch_ii/omitted_yield.md)
466467
- [Exhaustiveness](./switch_ii/exhaustiveness.md)
467468
- [Return a Switch](./switch_ii/return_a_switch.md)
469+
- [Challenges](./switch_ii/challenges.md)
468470

469471
# Code Structure IV
470472

@@ -475,26 +477,30 @@ BFS
475477
- [File names](./multi_file_programs/file_names.md)
476478
- [The Anonymous Main Class](./multi_file_programs/the_anonymous_main_class.md)
477479
- [Global Fields](./multi_file_programs/global_fields.md)
480+
- [Challenges](./multi_file_programs/challenges.md)
478481
- [Visibility](./visibility.md)
479482
- [Private Methods](./visibility/private_methods.md)
480483
- [Private Fields](./visibility/private_fields.md)
481484
- [Invariants](./visibility/invariants.md)
482485
- [Accessors](./visibility/accessors.md)
483486
- [Getters and Setters](./visibility/getter_and_setters.md)
487+
- [Challenges](./visibility/challenges.md)
484488
- [Static Fields](./static_fields.md)
485489
- [Declaration](./static_fields/declaration.md)
486490
- [Initialization](./static_fields/initialization.md)
487491
- [Usage](./static_fields/usage.md)
488492
- [Constants](./static_fields/constants.md)
489493
- [Controversy](./static_fields/controversy.md)
490494
- [Naming](./static_fields/naming.md)
495+
- [Challenges](./static_fields/challenges.md)
491496
- [Static Methods](./static_methods.md)
492497
- [Declaration](./static_methods/declaration.md)
493498
- [Scope](./static_methods/scope.md)
494499
- [Naming](./static_methods/naming.md)
495500
- [Usage](./static_methods/usage.md)
496501
- [Math](./static_methods/math.md)
497502
- [Factories](./static_methods/factories.md)
503+
- [Challenges](./static_methods/challenges.md)
498504

499505
# Data Structures & Algorithms
500506

src/constructors/challenges.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Challenges
22

3+
Remember the rules for this are
4+
35
- Try to use only the information given up to this point in this book.
46
- Try not to give up until you've given it a solid attempt
57

src/exceptions_ii/challenges.md

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

src/global_fields/challenges.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,83 @@
11
# 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 method named `anothaOne`. Each time this method is
11+
called it should return a number one larger than the last time
12+
it was called.
13+
14+
`anothaOne` should take no arguments.
15+
16+
```java,editable
17+
// CODE HERE
18+
19+
int anothaOne() {
20+
// CODE HERE
21+
}
22+
23+
void main() {
24+
IO.println(anothaOne()); // 1
25+
IO.println(anothaOne()); // 2
26+
IO.println(anothaOne()); // 3
27+
IO.println(anothaOne()); // 4
28+
IO.println(anothaOne()); // 5
29+
}
30+
```
31+
32+
## Challenge 2
33+
34+
Make a class named `DJKhaled`. If you ask DJ Khaleed to `produceMusic`
35+
some lyrics should be printed out but also `anothaOne` should be called at least 7 times.[^drake]
36+
37+
38+
```java,editable
39+
// CODE FROM LAST SECTION
40+
41+
class DJKhaled {
42+
void produceMusic() {
43+
// CODE HERE
44+
}
45+
}
46+
47+
void main() {
48+
IO.println(anothaOne()); // 1
49+
var dj = new DJKhaled();
50+
dj.produceMusic();
51+
IO.println(anothaOne()); // 8+, at least
52+
}
53+
```
54+
55+
## Challenge 3
56+
57+
Make a method named `nextLyric`. It should take no arguments and return a `String`.
58+
Each time it is called it should return a subsequent line from [Kendrick Lamar's 2025 Superbowl
59+
Halftime Show](https://www.youtube.com/watch?v=KDorKy-13ak).
60+
61+
You should be able to find a transcription of the lyrics [here](https://genius.com/Kendrick-lamar-and-nfl-super-bowl-lix-halftime-show-lyrics).
62+
63+
Once all the lyrics are exhausted `nextLyric` should start returning `null`.
64+
65+
```java,editable
66+
// CODE HERE
67+
68+
String nextLyric() {
69+
// CODE HERE
70+
}
71+
72+
void main() {
73+
for (
74+
String lyric = nextLyric();
75+
lyric != null;
76+
lyric = nextLyric()
77+
) {
78+
IO.println(lyric);
79+
}
80+
}
81+
```
82+
83+
[^drake]: We are just going to have fun with the "anotha one" meme here, lets not think too hard about DJ Khaled's relationship with Drake.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Challenges

src/projects/ascii_art.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,13 @@ And here it is with a height of `1`
9898
|
9999
```
100100

101-
You want to make sure that if the person using your program gives you a negative number, zero, or something that is
102-
not a number you don't just crash. This means you might need to reprompt them for information.
101+
103102

104103

105104
## Future Goals
106105

106+
When you learn enough to do the following, come back to this project and expand it.
107+
107108
* Draw something with more varied parts, like a snowman. You might find it convenient to not directly print to the screen, but instead "draw" what you want to print into an array first then print the contents of that array.
108109

109110
```
@@ -128,7 +129,8 @@ not a number you don't just crash. This means you might need to reprompt them fo
128129
| |
129130
\---------/
130131
```
131-
132+
* Make sure that if the person using your program gives you a negative number, zero, or something that is
133+
not a number you don't just crash. This means you might need to reprompt them for information.
132134
* Make the christmas tree prettier. This will require "finding the pattern" in a more interesting piece of art, like [this example](https://www.asciiart.eu/holiday-and-events/christmas/trees).
133135

134136
```

src/projects/point_of_sale_system.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The products the produce stand sells are as follows:
5151

5252
Customers may purchase any amount of any items in any combination.
5353

54-
Make sure to:
54+
Make sure to at least:
5555

5656
* Track the total for an order.
5757
* Prompt the cashier for the right quantities and weights.
@@ -60,15 +60,17 @@ Make sure to:
6060

6161
## Future Goals
6262

63+
When you learn enough to do the following, come back to this project and expand it.
64+
6365
* Grow your program to support double or triple the number of available items.
6466
* Make it so that the cashier has to "log in" to use the system
6567
* Account for a manager whose job it is to record how much money is in the register before and after a day of operations
6668
and note any unaccounted for funds.
6769
* Make the program not lose information if the computer running it turns off then on again.
6870
* Make the system work for "self check out," where the person entering the items is also the customer. Theft in
6971
these cases is monitored via security cameras and punished via the might of the police state.
70-
* Use a camera attached to the computer to scan a bar code which contains the product number
71-
* Optionally print a receipt for each order to a physical printer.
72+
* Use a camera attached to the computer to scan a bar code which contains the product number.
73+
* Optionally print a receipt for each order to a physical printer..
7274

7375

7476

src/static_fields/challenges.md

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

src/static_methods/challenges.md

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

src/switch_ii/challenges.md

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

0 commit comments

Comments
 (0)