Skip to content

Commit 5ceb119

Browse files
committed
update to ChooseYourOwnAdv w/@samanthalangit
1 parent 998501b commit 5ceb119

2 files changed

Lines changed: 82 additions & 84 deletions

File tree

0 Bytes
Binary file not shown.
Lines changed: 82 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,90 @@
11
package org.teachingkidsprogramming.section03ifs;
22

3+
import java.awt.Color;
4+
5+
import org.teachingextensions.approvals.lite.util.ThreadUtils;
6+
import org.teachingextensions.logo.Tortoise;
7+
import org.teachingextensions.logo.utils.ColorUtils.PenColors;
8+
import org.teachingextensions.logo.utils.EventUtils.MessageBox;
9+
310
public class ChooseYourOwnAdventure
411
{
512
public static void main(String[] args)
613
{
7-
// startStory (recipe below) --#2.1
8-
//
9-
// ------------- Recipe for startStory --#2.2
10-
// Tell the user "One morning the Tortoise woke up in a dream." --#1
11-
//
12-
// animateStartStory (recipe below) --#38.1
13-
//
14-
// ------------- Recipe for animateStartStory --#38.2
15-
// Show the Tortoise --#37
16-
// The current pen color is black --#39.2
17-
// Do the following 25 times --#41.1
18-
// Turn the background to the current pen color --#39.1
19-
// Lighten the current pen color --#42
20-
// Wait for 100 milliseconds --#40
21-
// Repeat --#41.2
22-
// ------------- End of animateStartStory recipe --#38.3
23-
//
24-
// Ask the user "Do you want to 'wake up' or 'explore' the dream?" --#3
25-
// If they answer "wake up" --#6
26-
// wakeUp (recipe below) --#5.1
27-
//
28-
// ------------- Recipe for wakeUp --#5.2
29-
// Tell the user "You Wake up and have a boring day. The End." --#4
30-
// ------------- End of wakeUp recipe --#5.3
31-
// Otherwise, if they answer "explore" --#9
32-
// approachOoze (recipe below) --#8.1
33-
//
34-
// ------------- Recipe for approachOoze --#8.2
35-
// Tell the user "You approach a glowing, green bucket of ooze, worried that you will get in trouble, you pick up the bucket." --#7
36-
// Ask the user "Do you want to pour the ooze into the 'backyard' or 'toilet'?" --#13
37-
// If they answer "toilet" --#16
38-
// pourIntoToilet (recipe below) --#15.1
39-
//
40-
// ------------- Recipe for pourIntoToilet --#15.2
41-
// Tell the user "As you pour the ooze into the toilet it backs up, gurgles and explodes covering you in radio-active waste." --#14
42-
// Ask the user "Do you want to train to be a NINJA? 'Yes' or 'HECK YES'?" --#29
43-
// If they answer "yes" --#32
44-
// ninjaTortoise (recipe below) --#31.1
45-
//
46-
// ------------- Recipe for ninjaTortoise --#31.2
47-
// Tell the user "Awesome Dude! You live out the rest of your life fighting crimes and eating pizza!" --#30
48-
// ------------- End of ninjaTortoise recipe --#31.3
49-
//
50-
// Otherwise, if they answer "heck yes" --#34
51-
// ninjaTortoise (recipe below) --#33
52-
//
53-
// Otherwise, if they answer anything else --#36
54-
// badAnswer (recipe below) --#35
55-
//
56-
// ------------- End of pourIntoToilet recipe --#15.3
57-
//
58-
// Otherwise, if they answer "backyard" --#19
59-
// pourIntoBackyard (recipe below) --#18.1
60-
//
61-
// ------------- Recipe for pourIntoBackyard --#18.2
62-
// Tell the user "As you walk into the backyard a net scoops you up and a giant takes you to a boiling pot of water." --#17
63-
// Ask the user "As the man starts to prepare you as soup, do you... 'Scream' or 'Faint'?" --#21
64-
// If they answer "faint" --#24
65-
//
66-
// tortoiseSoup (recipe below) --#23.1
67-
//
68-
// ------------- Recipe for tortoiseSoup --#23.2
69-
// Tell the user "You made a delicious soup! Yum! The End." --#22
70-
// ------------- End of tortoiseSoup recipe --#23.3
71-
//
72-
// Otherwise, if they answer "scream" --#26
73-
// startStory (recipe below) --#25.1
74-
//
75-
// Otherwise, if they answer anything else --#28
76-
// badAnswer (recipe below) --#27
77-
//
78-
// ------------- End of pourIntoBackyard recipe --#18.3
79-
// Otherwise, if they answer anything else --#20
80-
// badAnswer (recipe below) --#19
81-
// ------------- End of approachOoze recipe --#8.3
82-
//
83-
// Otherwise, if they answer anything else --#12
84-
// badAnswer (recipe below) --#11.1
85-
//
86-
// ------------- Recipe for badAnswer --#11.2
87-
// Tell the user "You don't know how to read directions. You can't play this game. The End." --#10
88-
// ------------- End of badAnswer recipe --#11.3
89-
//
90-
// ------------- End of startStory recipe --#2.3
14+
startStory();
15+
}
16+
private static void startStory()
17+
{
18+
tellMoreStory("One morning the Tortoise woke up in a dream.");
19+
animateStartStory();
20+
String action = askAQuestion("Do you want to 'wake up' or 'explore' the dream?");
21+
if ("wake up".equalsIgnoreCase(action))
22+
{
23+
// wakeUp (recipe below) --#2.1
24+
// ------------- Recipe for wakeUp --#2.2
25+
// Tell the user "You Wake up and have a boring day. The End." --#1
26+
// ------------- End of wakeUp recipe --#2.3
27+
}
28+
else if ("explore".equalsIgnoreCase(action))
29+
{
30+
// approachOoze (recipe below) --#4.1
31+
// ------------- Recipe for approachOoze --#4.2
32+
// Tell the user "You approach a glowing, green bucket of ooze, worried that you will get in trouble, you pick up the bucket." --#3
33+
// Ask the user "Do you want to pour the ooze into the 'backyard' or 'toilet'?" --#7
34+
// If they answer "toilet" --#8.1
35+
// pourIntoToilet (recipe below) --#12.1
36+
// ------------- Recipe for pourIntoToilet --#12.2
37+
// Tell the user "As you pour the ooze into the toilet it backs up, gurgles and explodes covering you in radio-active waste." --#10
38+
// Ask the user "Do you want to train to be a NINJA? 'Yes' or 'HECK YES'?" --#11
39+
// If they answer "yes" --#13.1
40+
// Tell the user "Awesome Dude! You live out the rest of your life fighting crimes and eating pizza!" --#14
41+
// Otherwise, if they answer "heck yes" --#13.2
42+
// Tell the user "Awesome Dude! You live out the rest of your life fighting crimes and eating pizza!" --#15
43+
// Otherwise, if they answer anything else --#13.3
44+
// endStory --#16
45+
// ------------- End of pourIntoToilet recipe --#12.3
46+
// Otherwise, if they answer "backyard" --#8.2
47+
// pourIntoBackyard (recipe below) --#19.1
48+
// ------------- Recipe for pourIntoBackyard --#19.2
49+
// Tell the user "As you walk into the backyard a net scoops you up and a giant takes you to a boiling pot of water." --#17
50+
// Ask the user "As the man starts to prepare you as soup, do you... 'Scream' or 'Faint'?" --#18
51+
// If they answer "faint" --#20.1
52+
// Tell the user "You made a delicious soup! Yum! The End." --#21
53+
// Otherwise, if they answer "scream" --#20.2
54+
// startStory --#22
55+
// Otherwise, if they answer anything else --#20.3
56+
// endStory --#23
57+
// ------------- End of pourIntoBackyard recipe --#19.3
58+
// Otherwise, if they answer anything else --#8.3
59+
// endStory --#9
60+
// ------------- End of approachOoze recipe --#4.3
61+
}
62+
else
63+
{
64+
// endStory (recipe below) --#6.1
65+
// ------------- Recipe for endStory --#6.2
66+
// Tell the user "You don't know how to read directions. You can't play this game. The End." --#5
67+
// ------------- End of endStory recipe --#6.3
68+
}
69+
}
70+
private static void animateStartStory()
71+
{
72+
Tortoise.show();
73+
Color color = PenColors.Grays.Black;
74+
for (int i = 0; i < 25; i++)
75+
{
76+
Tortoise.getBackgroundWindow().setColor(color);
77+
color = PenColors.lighten(color);
78+
ThreadUtils.sleep(100);
79+
}
80+
}
81+
private static void tellMoreStory(String message)
82+
{
83+
MessageBox.showMessage(message);
84+
}
85+
private static String askAQuestion(String question)
86+
{
87+
String answer = MessageBox.askForTextInput(question);
88+
return answer;
9189
}
9290
}

0 commit comments

Comments
 (0)