Skip to content

Commit cc77f1b

Browse files
committed
wrote stubs for Course 4 Kata Questions
1 parent 6534327 commit cc77f1b

File tree

6 files changed

+288
-2
lines changed

6 files changed

+288
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.teachingkidsprogramming.recipes.completed.section04mastery.KataQuestions;
2+
3+
import org.teachingextensions.logo.Tortoise;
4+
5+
//
6+
//------------Knotting Ring Kata---------------//
7+
// Use the Tortoise to draw a knotted ring (draw the shape FIRST)
8+
// Implement the createColorPalette() method to set up your colors, use blue tones
9+
//
10+
// Write each of the English line comments (use at least 8 line comments)
11+
// Number each comment line at the end
12+
// Verify - step one - Translate EACH comment line into code
13+
// Verify - step two - Run your code after each line
14+
//
15+
public class CompleteKnottedRing
16+
{
17+
public static void main(String[] args)
18+
{
19+
Tortoise.show();
20+
createColorPalette();
21+
// Write more code here...
22+
}
23+
private static void createColorPalette()
24+
{
25+
// Implement this
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package org.teachingkidsprogramming.recipes.completed.section04mastery.KataQuestions;
2+
3+
import org.teachingextensions.logo.Tortoise;
4+
import org.teachingextensions.logo.utils.ColorUtils.ColorWheel;
5+
import org.teachingextensions.logo.utils.ColorUtils.PenColors;
6+
7+
//
8+
//------------Knotting Ring Kata---------------//
9+
// Use the Tortoise to draw a knotted ring (draw the shape FIRST)
10+
// Implement the createColorPalette() method to set up your colors, use blue tones
11+
// Write each of the English line comments (use at least 8 line comments)
12+
// Number each comment line at the end
13+
// Verify - step one - Translate EACH comment line into code
14+
// Verify - step two - Run your code after each line
15+
//
16+
public class CompleteKnottedRing_ANSWER
17+
{
18+
public static void main(String[] args)
19+
{
20+
Tortoise.show();
21+
// Make the tortoise move as fast as possible --#4
22+
Tortoise.setSpeed(10);
23+
createColorPalette();
24+
// Do the following 30 times --#10.1
25+
for (int i = 0; i < 30; i++)
26+
{
27+
// Change the pen color of the line the tortoise draws to the next color from the color wheel --#5
28+
Tortoise.setPenColor(ColorWheel.getNextColor());
29+
// drawSeptagonWithOverlap (recipe below) --#8.0
30+
drawSeptagonWithOverlap();
31+
// Turn the tortoise 1/30th of 360 degrees to the right --#9
32+
Tortoise.turn(360.0 / 30);
33+
// Turn the tortoise 5 more degrees to the right --#11
34+
Tortoise.turn(5);
35+
// Repeat --#10
36+
}
37+
}
38+
// ------------- Recipe for drawSeptagonWithOverlap --#7.1
39+
private static void drawSeptagonWithOverlap()
40+
{
41+
// Do the following 7 + 1 times --#3.1
42+
for (int i = 0; i < 8; i++)
43+
{
44+
// Move the tortoise 95 pixels --#1
45+
Tortoise.move(95);
46+
// Turn the tortoise 1/7th of 360 degrees to the right --#2
47+
Tortoise.turn(360.0 / 7);
48+
// Repeat --#3.2
49+
}
50+
// ------------- End of drawSeptagonWithOverlap recipe --#7.2
51+
}
52+
private static void createColorPalette()
53+
{
54+
ColorWheel.addColor(PenColors.Blues.DarkBlue);
55+
ColorWheel.addColor(PenColors.Blues.Aqua);
56+
ColorWheel.addColor(PenColors.Blues.DarkCyan);
57+
ColorWheel.addColor(PenColors.Blues.DarkSlateBlue);
58+
ColorWheel.addColor(PenColors.Blues.Blue);
59+
ColorWheel.addColor(PenColors.Blues.DodgerBlue);
60+
ColorWheel.addColor(PenColors.Blues.CornflowerBlue);
61+
ColorWheel.addColor(PenColors.Blues.Cyan);
62+
}
63+
}

src/main/java/org/teachingkidsprogramming/recipes/completed/section04mastery/DigiFlowerKataQuestion.java renamed to src/main/java/org/teachingkidsprogramming/recipes/completed/section04mastery/KataQuestions/DigiFlower_01.java

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

33
import java.awt.Color;
44

@@ -9,11 +9,14 @@
99
//
1010
//------------Kata Question---------------//
1111
// How would you change the shape of a flower petal?
12+
// Refactor the number of petals as a method
13+
// Refactor (rename) the petal-making method
14+
// Draw more than one flower
1215
// Write out the steps in English
1316
// Then translate the steps into code
1417
// Make sure to run after each line
1518
//
16-
public class DigiFlowerKataQuestion
19+
public class DigiFlower_01
1720
{
1821
public static void main(String[] args)
1922
{
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package org.teachingkidsprogramming.recipes.completed.section04mastery.KataQuestions;
2+
3+
import java.awt.Color;
4+
5+
import org.teachingextensions.logo.Tortoise;
6+
import org.teachingextensions.logo.utils.ColorUtils.ColorWheel;
7+
import org.teachingextensions.logo.utils.ColorUtils.PenColors;
8+
9+
//
10+
//------------Kata Question---------------//
11+
//How would you change the shape of a flower petal?
12+
//Refactor the number of petals as a method
13+
//Refactor (rename) the petal-making method
14+
//Draw more than one flower
15+
//Write out the steps in English
16+
//Then translate the steps into code
17+
//Make sure to run after each line
18+
//
19+
public class DigiFlower_02
20+
{
21+
public static void main(String[] args)
22+
{
23+
Tortoise.show();
24+
Tortoise.setSpeed(10);
25+
Tortoise.getBackgroundWindow().setBackground(PenColors.Grays.Silver);
26+
Tortoise.setPenWidth(3);
27+
createColorPalette();
28+
drawFlower();
29+
}
30+
private static void drawFlower()
31+
{
32+
for (int i = 0; i < 15; i++)
33+
{
34+
drawPetal();
35+
Tortoise.turn(360.0 / 15);
36+
}
37+
}
38+
private static void createColorPalette()
39+
{
40+
Color color1 = PenColors.Reds.Red;
41+
Color color2 = PenColors.Oranges.DarkOrange;
42+
Color color3 = PenColors.Yellows.Gold;
43+
Color color4 = PenColors.Yellows.Yellow;
44+
ColorWheel.addColor(color1);
45+
ColorWheel.addColor(color2);
46+
ColorWheel.addColor(color3);
47+
ColorWheel.addColor(color4);
48+
ColorWheel.addColor(color4);
49+
ColorWheel.addColor(color3);
50+
ColorWheel.addColor(color2);
51+
ColorWheel.addColor(color1);
52+
}
53+
private static void drawPetal()
54+
{
55+
for (int i = 0; i < 8; i++)
56+
{
57+
Tortoise.setPenColor(ColorWheel.getNextColor());
58+
Tortoise.move(50);
59+
Tortoise.turn(360.0 / 8);
60+
}
61+
}
62+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package org.teachingkidsprogramming.recipes.completed.section04mastery.KataQuestions;
2+
3+
import java.awt.Color;
4+
5+
import org.teachingextensions.logo.Tortoise;
6+
import org.teachingextensions.logo.utils.ColorUtils.ColorWheel;
7+
import org.teachingextensions.logo.utils.ColorUtils.PenColors;
8+
9+
//
10+
//------------Kata Question---------------//
11+
//How would you change the shape of a flower petal?
12+
//Refactor the number of petals as a method
13+
//Refactor (rename) the petal-making method
14+
//Draw more than one flower
15+
//Write out the steps in English
16+
//Then translate the steps into code
17+
//Make sure to run after each line
18+
//
19+
public class DigiFlower_03
20+
{
21+
public static void main(String[] args)
22+
{
23+
Tortoise.show();
24+
Tortoise.setSpeed(10);
25+
Tortoise.getBackgroundWindow().setBackground(PenColors.Grays.Silver);
26+
Tortoise.setPenWidth(3);
27+
createColorPalette();
28+
drawFlower();
29+
Tortoise.move(200);
30+
drawFlower();
31+
}
32+
private static void drawFlower()
33+
{
34+
for (int i = 0; i < 15; i++)
35+
{
36+
drawPetal();
37+
Tortoise.turn(360.0 / 15);
38+
}
39+
}
40+
private static void createColorPalette()
41+
{
42+
Color color1 = PenColors.Reds.Red;
43+
Color color2 = PenColors.Oranges.DarkOrange;
44+
Color color3 = PenColors.Yellows.Gold;
45+
Color color4 = PenColors.Yellows.Yellow;
46+
ColorWheel.addColor(color1);
47+
ColorWheel.addColor(color2);
48+
ColorWheel.addColor(color3);
49+
ColorWheel.addColor(color4);
50+
ColorWheel.addColor(color4);
51+
ColorWheel.addColor(color3);
52+
ColorWheel.addColor(color2);
53+
ColorWheel.addColor(color1);
54+
}
55+
private static void drawPetal()
56+
{
57+
for (int i = 0; i < 8; i++)
58+
{
59+
Tortoise.setPenColor(ColorWheel.getNextColor());
60+
Tortoise.move(50);
61+
Tortoise.turn(360.0 / 8);
62+
}
63+
}
64+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package org.teachingkidsprogramming.recipes.completed.section04mastery.KataQuestions;
2+
3+
import java.awt.Color;
4+
5+
import org.teachingextensions.logo.Tortoise;
6+
import org.teachingextensions.logo.utils.ColorUtils.ColorWheel;
7+
import org.teachingextensions.logo.utils.ColorUtils.PenColors;
8+
9+
//
10+
//------------Kata Question---------------//
11+
//How would you change the shape of a flower petal?
12+
//Refactor the number of petals as a method
13+
//Refactor (rename) the petal-making method
14+
//Draw more than one flower
15+
//Write out the steps in English
16+
//Then translate the steps into code
17+
//Make sure to run after each line
18+
//
19+
public class DigiFlower_04
20+
{
21+
public static void main(String[] args)
22+
{
23+
Tortoise.show();
24+
Tortoise.setSpeed(10);
25+
Tortoise.getBackgroundWindow().setBackground(PenColors.Grays.Silver);
26+
Tortoise.setPenWidth(3);
27+
createColorPalette();
28+
Tortoise.setX(150);
29+
Tortoise.setY(150);
30+
drawFlower();
31+
Tortoise.setX(400);
32+
Tortoise.setY(300);
33+
drawFlower();
34+
}
35+
private static void drawFlower()
36+
{
37+
for (int i = 0; i < 15; i++)
38+
{
39+
drawPetal();
40+
Tortoise.turn(360.0 / 15);
41+
}
42+
}
43+
private static void createColorPalette()
44+
{
45+
Color color1 = PenColors.Reds.Red;
46+
Color color2 = PenColors.Oranges.DarkOrange;
47+
Color color3 = PenColors.Yellows.Gold;
48+
Color color4 = PenColors.Yellows.Yellow;
49+
ColorWheel.addColor(color1);
50+
ColorWheel.addColor(color2);
51+
ColorWheel.addColor(color3);
52+
ColorWheel.addColor(color4);
53+
ColorWheel.addColor(color4);
54+
ColorWheel.addColor(color3);
55+
ColorWheel.addColor(color2);
56+
ColorWheel.addColor(color1);
57+
}
58+
private static void drawPetal()
59+
{
60+
for (int i = 0; i < 8; i++)
61+
{
62+
Tortoise.setPenColor(ColorWheel.getNextColor());
63+
Tortoise.move(50);
64+
Tortoise.turn(360.0 / 8);
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)