Skip to content

Commit b8dc3fb

Browse files
committed
Finished DD7
1 parent 4bd29a9 commit b8dc3fb

File tree

2 files changed

+55
-15
lines changed

2 files changed

+55
-15
lines changed
705 Bytes
Binary file not shown.

TeachingKidsProgramming/src/org/teachingkidsprogramming/section07events/DeepDive07Events.java

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99
import org.teachingextensions.logo.Tortoise;
1010
import org.teachingextensions.logo.Turtle;
1111
import org.teachingextensions.logo.Turtle.Animals;
12-
//This deepdive is in progress!
1312

14-
//
1513
public class DeepDive07Events
1614
{
1715
// How to do deep dive:
18-
// Step 1: Select the method name (xxx on line xx) Press the Run Button
16+
// Step 1: Select the method name (twoTortoises on line 30) Press the Run Button
1917
// PC: Ctrl+F11
2018
// Mac: Command+fn+F11
2119
// Step 2: Read the name of the method that failed
@@ -24,17 +22,6 @@ public class DeepDive07Events
2422
// Step 5: Advance to the next method
2523
// Do not change anything except the blank (___)
2624
//
27-
// concepts:
28-
// 'this' - instance(s) - multiple Tortoises
29-
// exploring Object methods other than Tortoise---Circle (TKP)...methods
30-
// events / multiple event listeners - right click - move events to new section?
31-
@Test
32-
public void stringsCanBeArrays() throws Exception
33-
{
34-
String[] words = {"happy ", ___};
35-
String result = words[0] + words[1];
36-
Assert.assertEquals("happy baby", result);
37-
}
3825
@Test
3926
public void twoTortoises() throws Exception
4027
{
@@ -98,7 +85,50 @@ public void feedTheNinjaTwo() throws Exception
9885
Pizza pizza = new Pizza();
9986
pizza.addTopping(Topping.Anchovy);
10087
boolean likedIt = karai.eatPizza(pizza);
101-
Assert.assertTrue("Karai starves! Wrong pizza!", _____);
88+
Assert.assertTrue("Karai turns greener! Wrong pizza!", _____);
89+
}
90+
@Test
91+
public void checkOutThePizza() throws Exception
92+
{
93+
Tortoise cecil = new Tortoise();
94+
cecil.likesTopping(Topping.Cheese);
95+
Pizza pizza = new Pizza();
96+
pizza.addTopping(Topping.Cheese);
97+
pizza.____();
98+
boolean likedIt = cecil.eatPizza(pizza);
99+
Assert.assertTrue("Cecil sends it back! Wrong pizza!", likedIt);
100+
}
101+
@Test
102+
public void feedAllTheNinjas() throws Exception
103+
{
104+
Tortoise[] tortoises = throwPizzaParty();
105+
Pizza pizza = new Pizza();
106+
pizza.____();
107+
for (Tortoise tortoise : tortoises)
108+
{
109+
gotASlice = tortoise.eatPizza(pizza);
110+
if (!gotASlice)
111+
{
112+
break;
113+
}
114+
}
115+
Assert.assertTrue("The ninja flips out - not enough pizza!", gotASlice);
116+
}
117+
@Test
118+
public void feedAllTheNinjasAgain() throws Exception
119+
{
120+
Tortoise[] tortoises = throwPizzaParty();
121+
Pizza pizza = new Pizza();
122+
pizza.superSizeIt();
123+
for (Tortoise tortoise : tortoises)
124+
{
125+
_____ = tortoise.eatPizza(pizza);
126+
if (!this.gotASlice)
127+
{
128+
break;
129+
}
130+
}
131+
Assert.assertTrue("The ninja flips out - not enough pizza!", this.gotASlice);
102132
}
103133
/**
104134
* Ignore the following, It's needed to run the homework
@@ -113,6 +143,16 @@ public void feedTheNinjaTwo() throws Exception
113143
*
114144
*
115145
*/
146+
private Tortoise[] throwPizzaParty()
147+
{
148+
Tortoise karai = new Tortoise();
149+
Tortoise cecil = new Tortoise();
150+
Tortoise michealangelo = new Tortoise();
151+
Tortoise fred = new Tortoise();
152+
Tortoise[] tortoises = {karai, cecil, michealangelo, fred};
153+
return tortoises;
154+
}
155+
private boolean gotASlice;
116156
public boolean _____ = false;
117157
public boolean ______ = true;
118158
public String ___ = "You need to fill in the blank ___";

0 commit comments

Comments
 (0)