Skip to content

Commit dc24fbe

Browse files
committed
cleaned w/@samanthalangit
1 parent 7ba6342 commit dc24fbe

8 files changed

Lines changed: 57 additions & 51 deletions

File tree

src/main/java/org/teachingextensions/logo/Wheel.java

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,51 @@
2121
*
2222
* @param <T> The kind of things that are in the wheel
2323
*/
24-
public class Wheel<T> {
25-
private List<T> list = new ArrayList<>();
26-
private int index = 0;
27-
28-
@SafeVarargs
29-
public Wheel(T... loadWith) {
30-
for (T t : loadWith) {
31-
add(t);
32-
}
33-
}
34-
35-
public Wheel() {
24+
public class Wheel<T>
25+
{
26+
private List<T> list = new ArrayList<>();
27+
private int index = 0;
28+
@SafeVarargs
29+
public Wheel(T... loadWith)
30+
{
31+
for (T t : loadWith)
32+
{
33+
add(t);
3634
}
37-
38-
public void add(T i) {
39-
list.add(i);
40-
}
41-
42-
public T next() {
43-
assertNonEmpty();
44-
if (index >= list.size()) {
45-
index = 0;
46-
}
47-
return list.get(index++);
35+
}
36+
public Wheel()
37+
{
38+
}
39+
public void add(T i)
40+
{
41+
list.add(i);
42+
}
43+
public T next()
44+
{
45+
assertNonEmpty();
46+
if (index >= list.size())
47+
{
48+
index = 0;
4849
}
49-
50-
private void assertNonEmpty() {
51-
if (list.isEmpty()) {
52-
String message = "I call shenanigans!!!\nThis Wheel is empty\nYou can NOT get something from the Wheel before you've added anything to it.";
53-
throw new RuntimeException(message);
54-
}
55-
}
56-
57-
public T getRandomFrom() {
58-
assertNonEmpty();
59-
int index = NumberUtils.getRandomInt(0, list.size());
60-
return list.get(index);
61-
}
62-
63-
public void empty() {
64-
list.clear();
65-
index = 0;
50+
return list.get(index++);
51+
}
52+
private void assertNonEmpty()
53+
{
54+
if (list.isEmpty())
55+
{
56+
String message = "I call shenanigans!!!\nThis ColorWheel is empty\nYou can NOT get a color from the Wheel before you've added anything to it.";
57+
throw new RuntimeException(message);
6658
}
59+
}
60+
public T getRandomFrom()
61+
{
62+
assertNonEmpty();
63+
int index = NumberUtils.getRandomInt(0, list.size());
64+
return list.get(index);
65+
}
66+
public void empty()
67+
{
68+
list.clear();
69+
index = 0;
70+
}
6771
}

src/main/java/org/teachingkidsprogramming/recipes/completed/section00demos/QuickShape.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,19 @@ public class QuickShape
99
{
1010
public static void main(String[] args) throws Exception
1111
{
12-
//Tip: Use the Tortoise to draw!
13-
//Draw a red square that is 50 pixels per side with a line that's 2 pixels thick
1412
Tortoise.setX(150);
13+
//Tip: Use the Tortoise to draw shapes!
14+
//Draw a red square that is 50 pixels per side with a line that's 2 pixels thick
1515
Tortoise.drawShape(4, PenColors.Reds.Red, 75, 4);
16-
//
1716
//Draw a blue hexagon that is 65 pixels per side with a line that's 40 pixels thick
1817
Tortoise.setX(425);
1918
Tortoise.drawShape(6, PenColors.Blues.Blue, 65, 40);
20-
//
2119
Tortoise.setX(250);
2220
Tortoise.setY(375);
2321
Random r = new Random();
2422
int sides = r.nextInt(10) + 1;
2523
//Draw a purple shape that is 50 pixel on each side with a line that's 10 pixels thick
2624
Tortoise.drawShape(sides, PenColors.Purples.Purple, 50, 10);
2725
}
26+
//See your "work" at http://virtualproctor.tkpjava.org
2827
}

src/main/java/org/teachingkidsprogramming/recipes/completed/section01forloops/RecipeForTestingVirtualProctor.java renamed to src/main/java/org/teachingkidsprogramming/recipes/completed/section00demos/RecipeForTestingVirtualProctor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.teachingkidsprogramming.recipes.completed.section01forloops;
1+
package org.teachingkidsprogramming.recipes.completed.section00demos;
22

33
import org.teachingextensions.logo.PenColors;
44
import org.teachingextensions.logo.Tortoise;

src/main/java/org/teachingkidsprogramming/recipes/completed/section07events/SimpleBubble.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public SimpleBubble()
2222
private void prepareColorPalette()
2323
{
2424
//------------- Recipe for prepareColorPalette --#7
25-
// Add alice blue to the color wheel --#4
26-
ColorWheel.addColor(PenColors.Blues.AliceBlue);
25+
// Add light steel blue to the color wheel --#4
26+
ColorWheel.addColor(PenColors.Blues.LightSteelBlue);
2727
// Add blue to the color wheel --#5
2828
ColorWheel.addColor(PenColors.Blues.Blue);
2929
// Add dark blue to the color wheel --#6

src/main/java/org/teachingkidsprogramming/recipes/completed/section07events/SimpleBubbleVariation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public SimpleBubbleVariation()
2323
}
2424
private void prepareColorPalette()
2525
{
26-
ColorWheel.addColor(PenColors.Blues.AliceBlue);
26+
ColorWheel.addColor(PenColors.Blues.LightSteelBlue);
2727
ColorWheel.addColor(PenColors.Blues.Blue);
2828
ColorWheel.addColor(PenColors.Blues.DarkBlue);
2929
ColorWheel.addColor(PenColors.Purples.Purple);

src/main/java/org/teachingkidsprogramming/recipes/completed/section07events/TortoiseMobile.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public TortoiseMobile()
2525
{
2626
Tortoise.getBackgroundWindow().addMouseRightClickListener(this);
2727
Tortoise.setSpeed(10);
28+
Tortoise.setPenColor(PenColors.Greens.Green);
29+
Tortoise.setPenWidth(4);
2830
clearTheScreen();
2931
prepareColorPalette();
3032
ImageIcon arrowIconL = new ImageIcon(

src/main/java/org/teachingkidsprogramming/section00demos/QuickShape.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ public class QuickShape
88
{
99
public static void main(String[] args) throws Exception
1010
{
11-
// Tip: Use the Tortoise to draw shapes!
1211
Tortoise.setX(150);
12+
// Tip: Use the Tortoise to draw shapes!
1313
// Draw a red square that is 50 pixels per side with a line that's 2 pixels thick -- #1
1414
//
1515
Tortoise.setX(425);
@@ -18,8 +18,9 @@ public static void main(String[] args) throws Exception
1818
Tortoise.setX(250);
1919
Tortoise.setY(375);
2020
Random r = new Random();
21-
int sides = r.nextInt(10) + 1; // use this to generate a random number of sides
21+
int sides = r.nextInt(10) + 1;
2222
// Draw a purple shape that is 50 pixel on each side with a line that's 10 pixels thick -- #3
2323
//
2424
}
25+
//See "your" work at http://virtualproctor.tkpjava.org
2526
}

src/main/java/org/teachingkidsprogramming/section07events/SimpleBubble.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public SimpleBubble()
1212
//
1313
// ------------- Recipe for prepareColorPalette --#7.2
1414
// Add purple to the color wheel --#2.3
15-
// Add alice blue to the color wheel --#4
15+
// Add light steel blue to the color wheel --#4
1616
// Add blue to the color wheel --#5
1717
// Add dark blue to the color wheel --#6
1818
// ------------- End of prepareColorPalette recipe --#7.3

0 commit comments

Comments
 (0)