Skip to content

Commit 55e078f

Browse files
committed
added FourSquareKata and Snowflake Kata
1 parent d5984a1 commit 55e078f

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.teachingkidsprogramming.recipes.completed.section02methods.KataQuestions;
2+
3+
//------------FourSquare Kata---------------//
4+
// Use the Tortoise to draw four squares, each with a width and height of 50 pixels
5+
// Write each of the English line comments (use at least 8 line comments)
6+
// Number each comment line at the end
7+
// Verify - step one - Translate EACH comment line into code
8+
// Verify - step two - Run your code after each line
9+
public class CompleteFourSquare
10+
{
11+
public static void main()
12+
{
13+
System.out.println("be sure to complete the main method to start");
14+
//TODO: write comments and then code here
15+
}
16+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.teachingkidsprogramming.recipes.completed.section03ifs.KataQuestions;
2+
3+
//------------Snowflake Kata---------------//
4+
// Use the Tortoise to draw a snowflake using triangles
5+
// Write each of the English line comments (use at least 8 line comments)
6+
// Number each comment line at the end
7+
// Verify - step one - Translate EACH comment line into code
8+
// Verify - step two - Run your code after each line
9+
public class CompleteSnowflake
10+
{
11+
//TODO: write comments and then code here
12+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.teachingkidsprogramming.recipes.completed.section03ifs.KataQuestions;
2+
3+
import org.teachingextensions.logo.Tortoise;
4+
import org.teachingextensions.logo.utils.ColorUtils.PenColors;
5+
6+
//------------Snowflake Kata---------------//
7+
public class CompleteSnowflakeAnswer
8+
{
9+
public static void main(String[] args)
10+
{
11+
setUpBackground();
12+
for (int i = 0; i < 6; i++)
13+
{
14+
makeStarTop(4);
15+
Tortoise.turn(-60);
16+
}
17+
}
18+
private static void makeStarTop(int starSides)
19+
{
20+
for (int i = 0; i < starSides - 1; i++)
21+
{
22+
makeTriangleTop(3);
23+
Tortoise.turn(-60);
24+
}
25+
Tortoise.move(45);
26+
Tortoise.turn(-60);
27+
Tortoise.move(45);
28+
}
29+
private static void makeTriangleTop(int triangleSides)
30+
{
31+
for (int i = 1; i < triangleSides - 1; i++)
32+
{
33+
Tortoise.move(60);
34+
Tortoise.turn(360 / triangleSides);
35+
Tortoise.move(60);
36+
}
37+
}
38+
private static void setUpBackground()
39+
{
40+
Tortoise.show();
41+
Tortoise.setX(400);
42+
Tortoise.setY(100);
43+
Tortoise.setSpeed(10);
44+
Tortoise.getBackgroundWindow().setBackground(PenColors.Whites.AliceBlue);
45+
Tortoise.setPenColor(PenColors.Grays.SlateGray);
46+
}
47+
}

0 commit comments

Comments
 (0)