File tree Expand file tree Collapse file tree 4 files changed +6
-6
lines changed Expand file tree Collapse file tree 4 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ class Broom {
34
34
class Witch {
35
35
Object pullFromHat () {
36
36
double r = Math . random();
37
- if (Math . random() < 0.25 ) {
37
+ if (r < 0.25 ) {
38
38
return new Spell (" Ensmallen" );
39
39
}
40
40
else if (r < 0.5 ) {
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ The problem with this is that Java isn't smart enough to know that you always in
12
12
void main() {
13
13
String name;
14
14
while (true) {
15
- String name = IO.readln("What is your name? ");
15
+ name = IO.readln("What is your name? ");
16
16
if (name.isBlank()) {
17
17
IO.println("Name cannot be blank!");
18
18
continue;
@@ -31,7 +31,7 @@ To get around this you can either give an explicit default value.
31
31
void main() {
32
32
String name = null;
33
33
while (true) {
34
- String name = IO.readln("What is your name? ");
34
+ name = IO.readln("What is your name? ");
35
35
if (name.isBlank()) {
36
36
IO.println("Name cannot be blank!");
37
37
continue;
@@ -52,7 +52,7 @@ to see that the code in the loop will run at least once.
52
52
void main() {
53
53
String name;
54
54
do {
55
- String name = IO.readln("What is your name? ");
55
+ name = IO.readln("What is your name? ");
56
56
if (name.isBlank()) {
57
57
IO.println("Name cannot be blank!");
58
58
continue;
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ enum StopLight {
32
32
void main() {
33
33
StopLight color;
34
34
while (true) {
35
- String colorString = IO.readln("What color was the stoplight? ");
35
+ String colorString = IO.readln("What color was the stoplight? ");
36
36
try {
37
37
color = StopLight.valueOf(colorString);
38
38
} catch (RuntimeException e) {
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ void main() {
13
13
}
14
14
```
15
15
16
- But if you happen to know a number milliseconds after January 1, 1970 UTC[ ^ epoch ] you
16
+ But if you happen to know the number of milliseconds since January 1, 1970 0:00 UTC[ ^ epoch ] , you
17
17
can get an ` Instant ` which represents that point in time with ` Instant.ofEpochMilli ` .
18
18
19
19
``` java
You can’t perform that action at this time.
0 commit comments