Skip to content

Commit df718d8

Browse files
committed
completed DeepDive06 w/Samantha
1 parent c5239f2 commit df718d8

File tree

2 files changed

+54
-9
lines changed

2 files changed

+54
-9
lines changed
0 Bytes
Binary file not shown.

TeachingKidsProgramming/src/org/teachingkidsprogramming/section06modelviewcontroller/DeepDive06ModelViewController.java

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.awt.Color;
44
import java.awt.Cursor;
5+
import java.util.HashMap;
56

67
import org.junit.Assert;
78
import org.junit.Test;
@@ -21,17 +22,20 @@ public class DeepDive06ModelViewController
2122
// Step 5: Advance to the next method
2223
// Do not change anything except the blank (___)
2324
//
24-
// concepts:
25-
// string concatenation, including int-> string conversions
26-
// MVC
2725
@Test
2826
public void stringsCanBeArrays() throws Exception
2927
{
30-
//create a new string from the strings "happy " + "baby"
3128
String[] words = {"happy ", ___};
3229
Assert.assertEquals("happy baby", words);
3330
}
3431
@Test
32+
public void numbersCanBeStrings() throws Exception
33+
{
34+
int numberOfBabies = ____;
35+
String words = "" + numberOfBabies + " happy babies";
36+
Assert.assertEquals("10 happy babies", words);
37+
}
38+
@Test
3539
public void trashtalkingFlorida() throws Exception
3640
{
3741
String compareThis = "is to";
@@ -69,6 +73,46 @@ public void infiniteB() throws Exception
6973
+ ___ + ". Mandelbrot.";
7074
Assert.assertEquals("The B in Benoît B. Mandelbrot stands for Benoît B. Mandelbrot.", analogy);
7175
}
76+
@Test
77+
public void expectTheResult() throws Exception
78+
{
79+
numbers.put(12, "dozen");
80+
numbers.put(144, "gross");
81+
numbers.put(20, "score");
82+
String aSomething = "A " + numbers.get(12) + ", a " + numbers.get(144) + ", and a " + numbers.get(20);
83+
String aCalculation = aSomething
84+
+ " plus three times the square root of four, divided by seven, plus five times eleven";
85+
String aResult = aCalculation + " is nine squared and not a bit more";
86+
Assert.assertEquals("A dozen, a gross, and a score plus three times the square root of four,"
87+
+ " divided by seven, plus five times eleven is nine squared and not a bit more", ___);
88+
}
89+
@Test
90+
public void lookUp() throws Exception
91+
{
92+
// (12 + 144 + 20 + 3 x 4^1/2) / 7 + 5 x 11 = 9² + 0
93+
numbers.put(12, "dozen");
94+
numbers.put(144, "gross");
95+
numbers.put(20, "score");
96+
String aSomething = "A " + numbers.get(____) + ", a " + numbers.get(____) + ", and a " + numbers.get(____);
97+
String aCalculation = aSomething
98+
+ " plus three times the square root of four, divided by seven, plus five times eleven";
99+
String aResult = aCalculation + " is nine squared and not a bit more";
100+
Assert.assertEquals("A dozen, a gross, and a score plus three times the square root of four,"
101+
+ " divided by seven, plus five times eleven is nine squared and not a bit more", aResult);
102+
}
103+
@Test
104+
public void inYourOwnWords() throws Exception
105+
{
106+
numbers.put(12, ___);
107+
numbers.put(144, ___);
108+
numbers.put(20, ___);
109+
String aSomething = "A " + numbers.get(12) + ", a " + numbers.get(144) + ", and a " + numbers.get(20);
110+
String aCalculation = aSomething
111+
+ " plus three times the square root of four, divided by seven, plus five times eleven";
112+
String aResult = aCalculation + " is nine squared and not a bit more";
113+
Assert.assertEquals("A dozen, a gross, and a score plus three times the square root of four,"
114+
+ " divided by seven, plus five times eleven is nine squared and not a bit more", aResult);
115+
}
72116
/**
73117
* Ignore the following, It's needed to run the homework
74118
*
@@ -82,11 +126,12 @@ public void infiniteB() throws Exception
82126
*
83127
*
84128
*/
85-
public boolean _____ = false;
86-
public boolean ______ = true;
87-
public String ___ = "You need to fill in the blank ___";
88-
public int ____ = 0;
89-
public Color _______;
129+
public boolean _____ = false;
130+
public boolean ______ = true;
131+
public String ___ = "You need to fill in the blank ___";
132+
public HashMap<Integer, String> numbers = new HashMap<Integer, String>();
133+
public int ____ = 0;
134+
public Color _______;
90135
public String ___()
91136
{
92137
return ___;

0 commit comments

Comments
 (0)