Skip to content

Commit 00ad05a

Browse files
committed
added SquareKata
1 parent 5058a48 commit 00ad05a

6 files changed

Lines changed: 129 additions & 14 deletions

File tree

src/main/java/org/teachingkidsprogramming/recipes/completed/section01forloops/SimpleSquare.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static void main(String[] args) throws Exception
1818
// Change the pen color of the line the tortoise draws to blue --#4
1919
Tortoise.setPenColor(PenColors.Blues.Blue);
2020
// Move the tortoise 50 pixels --#2
21-
Tortoise.move(75);
21+
Tortoise.move(50);
2222
// Turn the tortoise to the right (90 degrees) --#3
2323
Tortoise.turn(90);
2424
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.teachingkidsprogramming.recipes.completed.section09final;
2+
3+
import org.teachingextensions.logo.Tortoise;
4+
import org.teachingextensions.logo.utils.ColorUtils.PenColors;
5+
6+
public class SquareKata
7+
{
8+
public static void main(String[] args)
9+
{
10+
// Draw a square
11+
// HINT: Write each step in English FIRST, then translate to Java one line at a time
12+
// TIP: Be sure to run after each line of Java to make sure it works as expected
13+
// Show the tortoise --#1
14+
Tortoise.show();
15+
// Make the tortoise move as fast as possible --#6
16+
Tortoise.setSpeed(10);
17+
// Do the following 4 times --#5.1
18+
for (int i = 0; i < 4; i++)
19+
{
20+
// Change the pen color of the line the tortoise draws to blue --#4
21+
Tortoise.setPenColor(PenColors.Blues.Blue);
22+
// Move the tortoise 50 pixels --#2
23+
Tortoise.move(50);
24+
// Turn the tortoise to the right (90 degrees) --#3
25+
Tortoise.turn(90);
26+
}
27+
// Repeat --#5.2
28+
}
29+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package org.teachingkidsprogramming.recipes.completed.section09final;
2+
3+
import static org.junit.Assert.assertEquals;
4+
5+
import org.junit.Test;
6+
import org.teachingextensions.approvals.lite.ApprovalWriter;
7+
import org.teachingextensions.approvals.lite.Approvals;
8+
import org.teachingextensions.logo.Tortoise;
9+
10+
//--------------------This recipe is in progress-------------------------------//
11+
public class SquareKataTDD
12+
{
13+
// Draw a square
14+
// HINT: Write each step in English FIRST, then translate to Java one line at a time
15+
// TIP: Be sure to run after each line of Java to make sure it works as expected
16+
// Write tests using the Assert object via the TDD style shown below
17+
// TIP: Fix this test to make it pass to get started
18+
@Test
19+
public void test1Returns1()
20+
{
21+
String result = FizzBuzzTDD.convert(1);
22+
assertEquals("1", result);
23+
}
24+
@Test
25+
public void testShowsTheTortoise() throws Exception
26+
{
27+
//Set up
28+
Tortoise.show();
29+
ApprovalWriter approver = null;
30+
//Verify
31+
Approvals.verify(approver, "png");
32+
}
33+
@Test
34+
public void testMovesTheTortoise50()
35+
{
36+
//Set up
37+
//Verify
38+
}
39+
@Test
40+
public void testTurnsTheTortoise90()
41+
{
42+
//Set up
43+
//Verify
44+
}
45+
@Test
46+
public void testDrawsFourSides()
47+
{
48+
//Set up
49+
//Verify
50+
}
51+
}

src/main/java/org/teachingkidsprogramming/section06modelviewcontroller/OneFishTwoFish.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,33 @@
44
@SuppressWarnings("unused")
55
public class OneFishTwoFish
66
{
7-
// Create a Scanner to make a string
7+
// Create a Scanner to make a string --#1
88
public static void main(String[] args)
99
{
1010
makeAString();
1111
}
1212
public static void makeAString()
1313
{
1414
final String input = "1 fish 2 fish red fish blue fish,black fish,blue fish,old fish,new fish ";
15-
// Use your scanner with your input
16-
// Display a new line and "We have: " and the input and then a new line
17-
// Now, tell a story with a new Scanner instance
15+
// Use your scanner with your input --#2
16+
// Display a new line and "We have: " and the input and then a new line --#3
17+
// Now, tell a story with a new Scanner instance (tellAStory recipe) --#8
1818
}
19+
//-------recipe for tellAStory------------------------------------
1920
private static void tellAStory(final String input)
2021
{
21-
// Use 'fish' as the base text w/your scanner [story] HINT: useDelimeter
22-
// Get the next number to use in your scanner [story] HINT: nextInt
23-
// Get the next value to use in your scanner [story] HINT: next
24-
// Iterate over each fish [string] HINT: Interable
25-
// Create a new string iterator
26-
// Create a new scanner for your input
27-
// Use a comma to separate the strings in your story HINT: useDelimeter
28-
// Return the result
22+
// Use 'fish' as the base text w/your scanner [story] HINT: useDelimeter --#5
23+
// Get the next number to use in your scanner [story] HINT: nextInt --#7
24+
// Get the next value to use in your scanner [story] HINT: next --#9
25+
// Iterate over each fish [string] HINT: Interable --#10
26+
// Create a new string iterator --#11
27+
// Create a new scanner for your input --#12
28+
// Use a comma to separate the strings in your story HINT: useDelimeter --#13
29+
// Return the result --#6
2930
{
30-
// Display "And then: " and the fish in the console
31+
// Display "And then: " and the fish in the console --#14
3132
}
3233
System.out.println("");
34+
//------end recipe tellAStory--------------------------------------
3335
}
3436
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.teachingkidsprogramming.section09final;
2+
3+
public class SquareKata
4+
{
5+
public static void main(String[] args)
6+
{
7+
// Draw a square
8+
// HINT: Write each step in English FIRST, then translate to Java one line at a time
9+
// TIP: Be sure to run after each line of Java to make sure it works as expected
10+
}
11+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.teachingkidsprogramming.section09final;
2+
3+
//--------------------This recipe is in progress-------------------------------//
4+
import static org.junit.Assert.assertEquals;
5+
6+
import org.junit.Test;
7+
import org.teachingkidsprogramming.recipes.completed.section09final.FizzBuzzTDD;
8+
9+
public class SquareKataTDD
10+
{
11+
// Draw a square
12+
// HINT: Write each step in English FIRST, then translate to Java one line at a time
13+
// TIP: Be sure to run after each line of Java to make sure it works as expected
14+
// Write tests using the Assert object via the TDD style shown below
15+
// TIP: Fix this test to make it pass to get started
16+
@Test
17+
public void test1Returns1()
18+
{
19+
String result = FizzBuzzTDD.convert(1);
20+
assertEquals("2", result);
21+
}
22+
}

0 commit comments

Comments
 (0)