Skip to content

Commit 59a8d33

Browse files
committed
Refactor for PenColors
1 parent 8a36238 commit 59a8d33

28 files changed

Lines changed: 107 additions & 108 deletions

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

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

33
import java.awt.Color;
44

5-
import org.teachingextensions.logo.Colors;
5+
import org.teachingextensions.logo.PenColors;
66
import org.teachingextensions.logo.Tortoise;
77

88
public class BackgroundPhoto
@@ -21,7 +21,7 @@ public static void main(String[] args)
2121
for (int i = 1; i <= 75; i++)
2222
{
2323
// Set the current pen color to crimson --#8.1
24-
Color penColor = Colors.Reds.Crimson;
24+
Color penColor = PenColors.Reds.Crimson;
2525
// Use the current pen color for the line the tortoise draws --#8.2
2626
Tortoise.setPenColor(penColor);
2727
// Increase the length of a side by 1 pixel --#5

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

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

33
import java.awt.Color;
44

5-
import org.teachingextensions.logo.Colors;
5+
import org.teachingextensions.logo.PenColors;
66
import org.teachingextensions.logo.Tortoise;
77
import org.teachingextensions.windows.MessageBox;
88

@@ -174,15 +174,15 @@ private static void animateStartStory()
174174
{
175175
//Show the Tortoise
176176
Tortoise.show();
177-
// The current color is black
178-
Color color = Colors.Grays.Black;
177+
// The current pen color is black
178+
Color color = PenColors.Grays.Black;
179179
// Do the following 25 times --#5.1
180180
for (int i = 1; i <= 25; i++)
181181
{
182182
// Turn the background black --#22
183183
Tortoise.getBackgroundWindow().setColor(color);
184-
// lighten the current color
185-
color = Colors.lighten(color);
184+
// lighten the current pen color
185+
color = PenColors.lighten(color);
186186
// wait for 100 milliseconds
187187
ThreadUtils.sleep(100);
188188
// Repeat --#5.2

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.awt.Color;
44

55
import org.teachingextensions.logo.ColorWheel;
6-
import org.teachingextensions.logo.Colors;
6+
import org.teachingextensions.logo.PenColors;
77
import org.teachingextensions.logo.Tortoise;
88
import org.teachingextensions.logo.shapes.Circle;
99
import org.teachingextensions.logo.shapes.Text;
@@ -31,20 +31,20 @@ public ConnectTheDots()
3131
prepareColorPalette();
3232
}
3333
private static void prepareColorPalette()
34-
{ // ------------- Recipe for prepareColorPalette
34+
{ // ------------- Recipe for prepareColorPalette (HINT: Use PenColors)
3535
//
3636
// Add red to the color wheel
37-
ColorWheel.addColor(Colors.Reds.Red);
37+
ColorWheel.addColor(PenColors.Reds.Red);
3838
// Add green to the color wheel
39-
ColorWheel.addColor(Colors.Greens.Green);
39+
ColorWheel.addColor(PenColors.Greens.Green);
4040
// Add blue to the color wheel
41-
ColorWheel.addColor(Colors.Blues.Blue);
41+
ColorWheel.addColor(PenColors.Blues.Blue);
4242
// Add purple to the color wheel
43-
ColorWheel.addColor(Colors.Purples.Purple);
43+
ColorWheel.addColor(PenColors.Purples.Purple);
4444
// Add pink to the color wheel
45-
ColorWheel.addColor(Colors.Pinks.Pink);
45+
ColorWheel.addColor(PenColors.Pinks.Pink);
4646
// Add teal to the color wheel
47-
ColorWheel.addColor(Colors.Greens.Teal);
47+
ColorWheel.addColor(PenColors.Greens.Teal);
4848
}
4949
private void addDot(int x, int y)
5050
{

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.awt.Color;
44

55
import org.teachingextensions.logo.ColorWheel;
6-
import org.teachingextensions.logo.Colors;
6+
import org.teachingextensions.logo.PenColors;
77
import org.teachingextensions.logo.Tortoise;
88

99
public class DigiFlower
@@ -14,8 +14,8 @@ public static void main(String[] args)
1414
Tortoise.show();
1515
// Make the tortoise move as fast as possible --#7
1616
Tortoise.setSpeed(10);
17-
// Make the background silver --#8
18-
Tortoise.getBackgroundWindow().setBackground(Colors.Grays.Silver);
17+
// Make the background silver (use PenColors) --#8
18+
Tortoise.getBackgroundWindow().setBackground(PenColors.Grays.Silver);
1919
// Make the line the tortoise draws 3 pixels wide --#20
2020
Tortoise.setPenWidth(3);
2121
// CreateColorPalette (recipe below) --#9
@@ -32,14 +32,14 @@ public static void main(String[] args)
3232
// ------------- Recipe for CreateColorPalette --#9
3333
private static void createColorPalette()
3434
{
35-
// Color 1 is red --#3
36-
Color color1 = Colors.Reds.Red;
37-
// Color 2 is dark orange --#11
38-
Color color2 = Colors.Oranges.DarkOrange;
39-
// Color 3 is gold --#12
40-
Color color3 = Colors.Yellows.Gold;
41-
// Color 4 is yellow --#13
42-
Color color4 = Colors.Yellows.Yellow;
35+
// Pen Color 1 is red --#3
36+
Color color1 = PenColors.Reds.Red;
37+
// Pen Color 2 is dark orange --#11
38+
Color color2 = PenColors.Oranges.DarkOrange;
39+
// Pen Color 3 is gold --#12
40+
Color color3 = PenColors.Yellows.Gold;
41+
// Pen Color 4 is yellow --#13
42+
Color color4 = PenColors.Yellows.Yellow;
4343
// Add color 1 to the color wheel --#3.1
4444
ColorWheel.addColor(color1);
4545
// Add color 2 to the color wheel --#11.1
@@ -64,7 +64,7 @@ private static void drawOctogon()
6464
// Do the following 8 times --#6
6565
for (int i = 1; i <= 8; i++)
6666
{
67-
// Change the color of the line the tortoise draws to the next color on the color wheel --#4
67+
// Change the pen color of the line the tortoise draws to the next color on the color wheel --#4
6868
Tortoise.setPenColor(ColorWheel.getNextColor());
6969
// Move the tortoise 50 pixels --#2
7070
Tortoise.move(50);

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

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

3-
import org.teachingextensions.logo.Colors;
3+
import org.teachingextensions.logo.PenColors;
44
import org.teachingextensions.logo.Tortoise;
55

66
public class FourSquare
@@ -26,8 +26,8 @@ private static void drawSquare()
2626
// Do the following 4 times --#5
2727
for (int i = 0; i < 4; i++)
2828
{
29-
// Change the color of the line the tortoise draws to a random color --#3
30-
Tortoise.setPenColor(Colors.getRandomColor());
29+
// Change the pen color of the line the tortoise draws to a random color --#3
30+
Tortoise.setPenColor(PenColors.getRandomColor());
3131
// Move the tortoise 50 pixels --#2
3232
Tortoise.move(50);
3333
// Turn the tortoise 90 degrees to the right --#4

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

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

3-
import java.awt.Color;
4-
3+
import org.teachingextensions.logo.PenColors;
54
import org.teachingextensions.logo.Tortoise;
65

76
public class Houses
@@ -26,8 +25,8 @@ public static void main(String[] args)
2625
public static void drawHouse(int height)
2726
{
2827
// ------------- Recipe for DrawHouse --#9
29-
// Change the color of the line the tortoise draws to lightGray --#15
30-
Tortoise.setPenColor(Color.lightGray);
28+
// Change the pen color of the line the tortoise draws to lightGray --#15
29+
Tortoise.setPenColor(PenColors.Grays.LightGray);
3130
// Move the tortoise the height of a house --#1.1
3231
Tortoise.move(height);
3332
// Turn the tortoise 90 degrees to the right --#2

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

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

33
import org.teachingextensions.logo.ColorWheel;
4-
import org.teachingextensions.logo.Colors;
4+
import org.teachingextensions.logo.PenColors;
55
import org.teachingextensions.logo.Tortoise;
66

77
public class KnottedRing
@@ -15,7 +15,7 @@ public static void main(String[] args)
1515
// Do the following 30 times --#10
1616
for (int i = 0; i < 30; i++)
1717
{
18-
// Change the color of the line the tortoise draws to a random color from the color wheel --#5
18+
// Change the pen color of the line the tortoise draws to a random color from the color wheel --#5
1919
Tortoise.setPenColor(ColorWheel.getNextColor());
2020
// drawOctagonWithOverlap (recipe below) --#8
2121
drawOctagonWithOverlap();
@@ -28,23 +28,23 @@ public static void main(String[] args)
2828
}
2929
private static void createColorPalette()
3030
{
31-
// ------------- Recipe for createColorPalette --#6
31+
// ------------- Recipe for createColorPalette (HINT: Use PenColors) --#6
3232
// Add hot pink to the color wheel --#6
33-
ColorWheel.addColor(Colors.Pinks.HotPink);
33+
ColorWheel.addColor(PenColors.Pinks.HotPink);
3434
// Add red to the color wheel --#12
35-
ColorWheel.addColor(Colors.Reds.Red);
35+
ColorWheel.addColor(PenColors.Reds.Red);
3636
// Add fuchsia to the color wheel --#13
37-
ColorWheel.addColor(Colors.Pinks.Fuchsia);
37+
ColorWheel.addColor(PenColors.Pinks.Fuchsia);
3838
// Add orange red to the color wheel --#14
39-
ColorWheel.addColor(Colors.Reds.OrangeRed);
39+
ColorWheel.addColor(PenColors.Reds.OrangeRed);
4040
// Add deep pink to the color wheel --#15
41-
ColorWheel.addColor(Colors.Pinks.DeepPink);
41+
ColorWheel.addColor(PenColors.Pinks.DeepPink);
4242
// Add medium violet red to the color wheel --#16
43-
ColorWheel.addColor(Colors.Reds.MediumVioletRed);
43+
ColorWheel.addColor(PenColors.Reds.MediumVioletRed);
4444
// Add crimson to the color wheel --#17
45-
ColorWheel.addColor(Colors.Reds.Crimson);
45+
ColorWheel.addColor(PenColors.Reds.Crimson);
4646
// Add tomato to the color wheel --#18
47-
ColorWheel.addColor(Colors.Reds.Tomato);
47+
ColorWheel.addColor(PenColors.Reds.Tomato);
4848
// ------------- End of createColorPalette recipe --#6
4949
}
5050
private static void drawOctagonWithOverlap()

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

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

33
import org.teachingextensions.logo.ColorWheel;
4-
import org.teachingextensions.logo.Colors;
4+
import org.teachingextensions.logo.PenColors;
55
import org.teachingextensions.logo.Tortoise;
66

77
public class PentagonCrazy
@@ -15,19 +15,19 @@ public static void main(String[] args)
1515
// DrawPentagon (recipe below) --#10
1616
drawPentagon();
1717
}
18-
// ------------- Recipe for CreateColorPalette --#8
18+
// ------------- Recipe for CreateColorPalette (HINT: Use PenColors) --#8
1919
private static void createColorPalette()
2020
{
2121
// Add steel blue to the color wheel --#7
22-
ColorWheel.addColor(Colors.Blues.SteelBlue);
22+
ColorWheel.addColor(PenColors.Blues.SteelBlue);
2323
// Add dark orchid to the color wheel --#11
24-
ColorWheel.addColor(Colors.Purples.DarkOrchid);
24+
ColorWheel.addColor(PenColors.Purples.DarkOrchid);
2525
// Add dark slate blue to the color wheel --#12
26-
ColorWheel.addColor(Colors.Blues.DarkSlateBlue);
26+
ColorWheel.addColor(PenColors.Blues.DarkSlateBlue);
2727
// Add teal to the color wheel --#13
28-
ColorWheel.addColor(Colors.Blues.Teal);
28+
ColorWheel.addColor(PenColors.Blues.Teal);
2929
// Add indigo to the color wheel --#14
30-
ColorWheel.addColor(Colors.Purples.Indigo);
30+
ColorWheel.addColor(PenColors.Purples.Indigo);
3131
}
3232
// ------------- End of CreateColorPalette recipe
3333
// ------------- Recipe for AdjustPen --#9

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

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

33
import org.teachingextensions.logo.ColorWheel;
4-
import org.teachingextensions.logo.Colors;
4+
import org.teachingextensions.logo.PenColors;
55
import org.teachingextensions.logo.shapes.Circle;
66
import org.teachingextensions.windows.MouseLeftClickListener;
77
import org.teachingextensions.windows.ProgramWindow;
@@ -24,13 +24,13 @@ private void prepareColorPalette()
2424
{
2525
//------------- Recipe for prepareColorPalette --#7
2626
// Add alice blue to the color wheel --#4
27-
ColorWheel.addColor(Colors.Blues.AliceBlue);
27+
ColorWheel.addColor(PenColors.Blues.AliceBlue);
2828
// Add blue to the color wheel --#5
29-
ColorWheel.addColor(Colors.Blues.Blue);
29+
ColorWheel.addColor(PenColors.Blues.Blue);
3030
// Add dark blue to the color wheel --#6
31-
ColorWheel.addColor(Colors.Blues.DarkBlue);
31+
ColorWheel.addColor(PenColors.Blues.DarkBlue);
3232
// Add purple to the color wheel --#2.3
33-
ColorWheel.addColor(Colors.Purples.Purple);
33+
ColorWheel.addColor(PenColors.Purples.Purple);
3434
//------------- End of prepareColorPalette recipe --#7
3535
}
3636
@Override

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

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

3-
import org.teachingextensions.logo.Colors;
3+
import org.teachingextensions.logo.PenColors;
44
import org.teachingextensions.logo.Tortoise;
55
import org.teachingextensions.logo.Turtle.Animals;
66

@@ -14,8 +14,8 @@ public static void main(String[] args)
1414
Tortoise.setPenWidth(1);
1515
// Change the Tortoise to a Spider --#14
1616
Tortoise.setAnimal(Animals.Spider);
17-
// Change the color of the line the tortoise draws to silver --#13
18-
Tortoise.setPenColor(Colors.Grays.Silver);
17+
// Change the pen color of the line the tortoise draws to silver --#13
18+
Tortoise.setPenColor(PenColors.Grays.Silver);
1919
// The current length of a line is 10 pixels --#1.2
2020
double length = 10.5;
2121
// The current zoom is 1.1 --#8.2

0 commit comments

Comments
 (0)