@@ -11,180 +11,99 @@ public class ChooseYourOwnAdventure
1111{
1212 public static void main (String [] args )
1313 {
14- // startStory (recipe below) --#1
15- // ------------- Recipe for startStory --#1
1614 startStory ();
17- // ------------- End of startStory recipe --#1
1815 }
1916 private static void startStory ()
2017 {
21- //Tell the user "One morning the Tortoise woke up in a dream."
22- MessageBox .showMessage ("One morning the Tortoise woke up in a dream." );
23- // animateStartStory (recipe below) --#1
24- // ------------- Recipe for animateStartStory --#1
18+ tellMoreStory ("One morning the Tortoise woke up in a dream." );
2519 animateStartStory ();
26- // ------------- End of animateStartStory recipe --#1
27- // Ask the user "Do you want to 'wake up' or 'explore' the dream?"
28- String action = MessageBox .askForTextInput ("Do you want to 'wake up' or 'explore' the dream?" );
29- // If they answer "wake up" --#4
20+ String action = askAQuestion ("Do you want to 'wake up' or 'explore' the dream?" );
3021 if ("wake up" .equalsIgnoreCase (action ))
3122 {
32- // wakeUp (recipe below) --#1
33- // ------------- Recipe for wakeUp --#1
34- wakeUp ();
35- // ------------- End of wakeUp recipe --#1
23+ tellMoreStory ("You Wake up and have a boring day. The End." );
3624 }
37- //Otherwise, if they answer "explore"
3825 else if ("explore" .equalsIgnoreCase (action ))
3926 {
40- // approachOoze (recipe below) --#1
41- // ------------- Recipe for approachOoze --#1
4227 approachOoze ();
43- // ------------- End of approachOoze recipe --#1
4428 }
45- //Otherwise, if they answer anything else
4629 else
4730 {
48- // badAnswer (recipe below) --#1
49- // ------------- Recipe for badAnswer --#1
50- badAnswer ();
51- // ------------- End of badAnswer recipe --#1
31+ endStory ();
5232 }
5333 }
54- private static void badAnswer ()
34+ private static void endStory ()
5535 {
56- //Tell the user "You don't know how to read directions. You can't play this game. The End."
57- MessageBox .showMessage ("You don't know how to read directions. You can't play this game. The End." );
58- }
59- private static void wakeUp ()
60- {
61- //Tell the user "You Wake up and have a boring day. The End."
62- MessageBox .showMessage ("You Wake up and have a boring day. The End." );
36+ tellMoreStory ("You don't know how to read directions. You can't play this game. The End." );
6337 }
6438 private static void approachOoze ()
6539 {
66- //Tell the user "You approach a glowing, green bucket of ooze, worried that you will get in trouble, you pick up the bucket."
67- MessageBox
68- .showMessage ("You approach a glowing, green bucket of ooze, worried that you will get in trouble, you pick up the bucket." );
69- //
70- // Ask the user "Do you want to pour the ooze into the 'backyard' or 'toilet'?"
71- String pourTo = MessageBox .askForTextInput (" Do you want to pour the ooze into the 'backyard' or 'toilet'?" );
72- // If they answer "toilet" --#4
40+ tellMoreStory ("You approach a glowing, green bucket of ooze, worried that you will get in trouble, you pick up the bucket." );
41+ String pourTo = askAQuestion (" Do you want to pour the ooze into the 'backyard' or 'toilet'?" );
7342 if ("toilet" .equalsIgnoreCase (pourTo ))
7443 {
75- // pourIntoToilet (recipe below) --#1
76- // ------------- Recipe for pourIntoToilet --#1
7744 pourIntoToilet ();
78- // ------------- End of pourIntoToilet recipe --#1
7945 }
80- // Otherwise, if they answer "backyard" --#4
8146 else if ("backyard" .equalsIgnoreCase (pourTo ))
8247 {
83- // pourIntoBackyard (recipe below) --#1
84- // ------------- Recipe for pourIntoBackyard --#1
8548 pourIntoBackyard ();
86- // ------------- End of pourIntoBackyard recipe --#1
8749 }
88- //Otherwise, if they answer anything else
8950 else
9051 {
91- // badAnswer (recipe below) --#1
92- // ------------- Recipe for badAnswer --#1
93- badAnswer ();
94- // ------------- End of badAnswer recipe --#1
52+ endStory ();
9553 }
9654 }
97- private static void pourIntoBackyard ()
55+ private static void pourIntoToilet ()
9856 {
99- //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."
100- MessageBox
101- .showMessage ("As you walk into the backyard a net scoops you up and a giant takes you to a boiling pot of water." );
102- //Ask the user "As the man starts to prepare you as soup, do you... 'Scream' or 'Faint'?"
103- String action = MessageBox
104- .askForTextInput ("As the man starts to prepare you as soup, do you... 'Scream' or 'Faint'?" );
105- // If they answer "faint" --#4
106- if ("faint" .equalsIgnoreCase (action ))
57+ tellMoreStory ("As you pour the ooze into the toilet it backs up, gurgles and explodes covering you in radio-active waste." );
58+ String pourTo = askAQuestion ("Do you want to train to be a NINJA? 'Yes' or 'HECK YES'?" );
59+ if ("yes" .equalsIgnoreCase (pourTo ))
10760 {
108- // tortoiseSoup (recipe below) --#1
109- // ------------- Recipe for tortoiseSoup --#1
110- tortoiseSoup ();
111- // ------------- End of tortoiseSoup recipe --#1
61+ tellMoreStory ("Awesome Dude! You live out the rest of your life fighting crimes and eating pizza!" );
11262 }
113- // Otherwise, if they answer "scream" --#4
114- else if ("scream" .equalsIgnoreCase (action ))
63+ else if ("heck yes" .equalsIgnoreCase (pourTo ))
11564 {
116- // startStory (recipe below) --#1
117- // ------------- Recipe for startStory --#1
118- startStory ();
119- // ------------- End of startStory recipe --#1
65+ tellMoreStory ("Awesome Dude! You live out the rest of your life fighting crimes and eating pizza!" );
12066 }
121- //Otherwise, if they answer anything else
12267 else
12368 {
124- // badAnswer (recipe below) --#1
125- // ------------- Recipe for badAnswer --#1
126- badAnswer ();
127- // ------------- End of badAnswer recipe --#1
69+ endStory ();
12870 }
12971 }
130- private static void tortoiseSoup ()
131- {
132- //Tell the user "You made a delicious soup! Yum! The End."
133- MessageBox .showMessage ("You made a delicious soup! Yum! The End." );
134- }
135- private static void pourIntoToilet ()
72+ private static void pourIntoBackyard ()
13673 {
137- //Tell the user "As you pour the ooze into the toilet it backs up, gurgles and explodes covering you in radio-active waste."
138- MessageBox
139- .showMessage ("As you pour the ooze into the toilet it backs up, gurgles and explodes covering you in radio-active waste." );
140- //Ask the user "Do you want to train to be a NINJA? 'Yes' or 'HECK YES'?"
141- String pourTo = MessageBox .askForTextInput ("Do you want to train to be a NINJA? 'Yes' or 'HECK YES'?" );
142- // If they answer "yes" --#4
143- if ("yes" .equalsIgnoreCase (pourTo ))
74+ tellMoreStory ("As you walk into the backyard a net scoops you up and a giant takes you to a boiling pot of water." );
75+ String action = askAQuestion ("As the man starts to prepare you as soup, do you... 'Scream' or 'Faint'?" );
76+ if ("faint" .equalsIgnoreCase (action ))
14477 {
145- // ninjaTortoise (recipe below) --#1
146- // ------------- Recipe for ninjaTortoise --#1
147- ninjaTortoise ();
148- // ------------- End of ninjaTortoise recipe --#1
78+ tellMoreStory ("You made a delicious soup! Yum! The End." );
14979 }
150- // Otherwise, if they answer "heck yes" --#4
151- else if ("heck yes" .equalsIgnoreCase (pourTo ))
80+ else if ("scream" .equalsIgnoreCase (action ))
15281 {
153- // ninjaTortoise (recipe below) --#1
154- // ------------- Recipe for ninjaTortoise --#1
155- ninjaTortoise ();
156- // ------------- End of ninjaTortoise recipe --#1
82+ startStory ();
15783 }
158- //Otherwise, if they answer anything else
15984 else
16085 {
161- // badAnswer (recipe below) --#1
162- // ------------- Recipe for badAnswer --#1
163- badAnswer ();
164- // ------------- End of badAnswer recipe --#1
86+ endStory ();
16587 }
16688 }
167- private static void ninjaTortoise ()
168- {
169- //Tell the user "Awesome Dude! You live out the rest of your life fighting crimes and eating pizza!"
170- MessageBox .showMessage ("Awesome Dude! You live out the rest of your life fighting crimes and eating pizza!" );
171- }
17289 private static void animateStartStory ()
17390 {
174- //Show the Tortoise
17591 Tortoise .show ();
176- // The current pen color is black
17792 Color color = PenColors .Grays .Black ;
178- // Do the following 25 times --#5.1
17993 for (int i = 0 ; i < 25 ; i ++)
18094 {
181- // Turn the background black --#22
18295 Tortoise .getBackgroundWindow ().setColor (color );
183- // lighten the current pen color
18496 color = PenColors .lighten (color );
185- // wait for 100 milliseconds
18697 ThreadUtils .sleep (100 );
187- // Repeat --#5.2
18898 }
18999 }
100+ private static void tellMoreStory (String message )
101+ {
102+ MessageBox .showMessage (message );
103+ }
104+ private static String askAQuestion (String question )
105+ {
106+ String answer = MessageBox .askForTextInput (question );
107+ return answer ;
108+ }
190109}
0 commit comments