Skip to content

Commit 8c841b3

Browse files
committed
Working on DD7 w/Jim
1 parent 225ac98 commit 8c841b3

6 files changed

Lines changed: 64 additions & 15 deletions

File tree

src/org/teachingextensions/logo/TurtlePanel.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616

1717
public class TurtlePanel extends ProgramWindow
1818
{
19-
private Turtle turtle;
20-
private Image image;
19+
private Turtle turtle;
20+
private Image image;
21+
private Animals animal;
2122
public TurtlePanel()
2223
{
2324
}
@@ -71,8 +72,17 @@ public synchronized Image getImage()
7172
}
7273
return image;
7374
}
75+
public synchronized Animals getAnimal()
76+
{
77+
if (animal == null)
78+
{
79+
setAnimal(Animals.Turtle);
80+
}
81+
return animal;
82+
}
7483
public synchronized void setAnimal(Animals animal)
7584
{
85+
this.animal = animal;
7686
image = new ImageIcon(this.getClass().getResource(animal + ".png")).getImage();
7787
}
7888
public void setCursor(int cursor)

src/org/teachingkidsprogramming/recipes/completed/ConnectTheDots.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ConnectTheDots implements MouseRightClickListener, MouseLeftClickLi
1414
{
1515
public static void main(String[] args)
1616
{
17-
//Create a Connect the Dots window.
17+
//Create new a 'Connect the Dots' window.
1818
ConnectTheDots dots = new ConnectTheDots();
1919
}
2020
public ConnectTheDots()

src/org/teachingkidsprogramming/recipes/completed/HolidayCard.java renamed to src/org/teachingkidsprogramming/recipes/completed/SmallBasicHolidayCard.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package org.teachingkidsprogramming.recipes.completed;
22

3-
public class HolidayCard
3+
public class SmallBasicHolidayCard
44
{
5+
//**needs to be translated from the SmallBasic
56
// Holiday Recipe - Enjoy!
67
// Set the background to the color of Snow
78
//

src/org/teachingkidsprogramming/recipes/completed/TicTacToe.java renamed to src/org/teachingkidsprogramming/recipes/completed/SmallBasicTicTacToe.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package org.teachingkidsprogramming.recipes.completed;
22

3-
public class TicTacToe
3+
public class SmallBasicTicTacToe
44
{
5+
//**needs to be translated from the SmallBasic**
6+
57
// Tell TicTacToe to call PlayInFirstEmptySpot (recipe below) when its Xs turn
68
//
79
// Start TicTacToe

src/org/teachingkidsprogramming/section07events/ConnectTheDots.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class ConnectTheDots implements MouseRightClickListener, MouseLeftClickLi
77
{
88
public static void main(String[] args)
99
{
10-
//Create a Connect The Dots window. --#1.1
10+
//Create a new 'Connect The Dots' window. --#1.1
1111
}
1212
public ConnectTheDots()
1313
{

src/org/teachingkidsprogramming/section07events/DeepDive07Events.java

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package org.teachingkidsprogramming.section07events;
22

3-
import java.awt.Color;
43
import java.awt.Cursor;
54

65
import org.junit.Assert;
76
import org.junit.Test;
87
import org.teachingextensions.logo.Tortoise;
8+
import org.teachingextensions.logo.Turtle;
99
//This deepdive is in progress!
1010

1111
//@Ignore
@@ -21,17 +21,52 @@ public class DeepDive07Events
2121
// Step 5: Advance to the next method
2222
// Do not change anything except the blank (___)
2323
//
24-
// concepts:
25-
// events
26-
// event listeners - right click
24+
// concepts:
25+
// events / multiple event listeners - right click
2726
// 'this' - instance(s) - multiple Tortoises
27+
// exploring Object methods other than Tortoise---Circle (TKP)...methods
2828
@Test
2929
public void concatenateString() throws Exception
3030
{
3131
//create a new string from the strings "happy " + "baby"
3232
String[] words = {"happy ", ___};
3333
Assert.assertEquals("happy baby", words);
3434
}
35+
@Test
36+
public void twoTortoises() throws Exception
37+
{
38+
Tortoise rafael = new Tortoise();
39+
Tortoise michealangelo = new Tortoise();
40+
boolean result = rafael.equals(michealangelo);
41+
Assert.assertEquals(______, result);
42+
}
43+
@Test
44+
public void twoTortoisesAgain() throws Exception
45+
{
46+
Tortoise rafael = new Tortoise();
47+
Tortoise anonymousNinja = rafael;
48+
boolean result = rafael.equals(anonymousNinja);
49+
Assert.assertEquals(_____, result);
50+
}
51+
@Test
52+
public void twoTortoisesYetAgain() throws Exception
53+
{
54+
Tortoise rafael = new Tortoise();
55+
Tortoise michealangelo = new Tortoise();
56+
Tortoise anonymousNinja = ________;
57+
boolean result = michealangelo.equals(anonymousNinja);
58+
Assert.assertEquals(true, result);
59+
}
60+
//"this" Tortoise belongs here (to this Object)
61+
private Turtle leonardo;
62+
@Test
63+
public void sadTortoise() throws Exception
64+
{
65+
this._______ = new Turtle();
66+
//sorry, leonardo must die now - joking
67+
this.leonardo.getPenWidth();
68+
Assert.assertEquals(2, this.leonardo.getPenWidth());
69+
}
3570
/**
3671
* Ignore the following, It's needed to run the homework
3772
*
@@ -45,11 +80,12 @@ public void concatenateString() throws Exception
4580
*
4681
*
4782
*/
48-
public boolean _____ = false;
49-
public boolean ______ = true;
50-
public String ___ = "You need to fill in the blank ___";
51-
public int ____ = 0;
52-
public Color _______;
83+
public boolean _____ = false;
84+
public boolean ______ = true;
85+
public String ___ = "You need to fill in the blank ___";
86+
public int ____ = 0;
87+
public Turtle _______;
88+
public Tortoise ________;
5389
public String ___()
5490
{
5591
return ___;

0 commit comments

Comments
 (0)