Skip to content

Commit 7dacd66

Browse files
committed
added stub for ExceptionalAdLibs w/ @samanthalangit
1 parent 45e0d69 commit 7dacd66

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

  • src/main/java/org/teachingkidsprogramming/recipes/completed/section06modelviewcontroller
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package org.teachingkidsprogramming.recipes.completed.section06modelviewcontroller;
2+
3+
import org.teachingextensions.windows.MessageBox;
4+
5+
//***********this recipe is in development - watch for updates!**************
6+
public class ExceptionalAdLibs
7+
{
8+
public static void main(String[] args)
9+
{
10+
//Ask the user to enter an adverb, save it as currentAdverb --#2
11+
String adverb = MessageBox.askForTextInput("What is the adverb?");
12+
if (adverb.isEmpty())
13+
{
14+
MessageBox.showMessage("Required value, pay attention and start over");
15+
return;
16+
}
17+
else if (adverb.matches("[\\d]"))
18+
{
19+
MessageBox.showMessage("Numbers are NOT adverbs, try again");
20+
return;
21+
}
22+
String currentAdverb = adverb;
23+
//Ask the user to enter a verb ending in '-ed', save it as currentEdVerb --#4
24+
String edverb = MessageBox.askForTextInput("What is the -ed verb?");
25+
if (edverb.isEmpty())
26+
{
27+
MessageBox.showMessage("Don't like verbs? Sorry you need one now, pay attention and start over");
28+
return;
29+
}
30+
else if (edverb.matches("[\\d]"))
31+
{
32+
MessageBox.showMessage("Numbers are NOT verbs, try again");
33+
return;
34+
}
35+
String currentEdVerb = edverb;
36+
//Ask the user to enter a body part, save it as currentBodyPart --#6
37+
String currentBodyPart = MessageBox.askForTextInput("What is the body part?");
38+
//Set the value of the currentStory to the word "Today " --#1.2
39+
String currentStory = "Today ";
40+
//Add the words "I woke " + currentAdverb + ". " to the currentStory --#3
41+
currentStory = currentStory + "I woke " + currentAdverb + ". ";
42+
//Add the words '"Then I " + currentEdVerb + " " to the currentStory --#5
43+
currentStory = currentStory + "Then I " + currentEdVerb + " ";
44+
//Add the words "my " + currentBodyPart + ". " to the current story --#7
45+
currentStory = currentStory + "my " + currentBodyPart + ". ";
46+
//Show the currentStory in a message box as a message --#1.1
47+
MessageBox.showMessage(currentStory);
48+
}
49+
}

0 commit comments

Comments
 (0)