Skip to content

Commit 3762ee9

Browse files
committed
added refactoring kata w/@dcoopersmith
Giza
1 parent 04fce0f commit 3762ee9

File tree

4 files changed

+66
-6
lines changed

4 files changed

+66
-6
lines changed

src/main/java/org/teachingkidsprogramming/recipes/completed/section02methods/KataQuestions/HousesToAColorfulPointyAndASlantedRoof_05.java renamed to src/main/java/org/teachingkidsprogramming/recipes/completed/section02methods/KataQuestions/HousesToAColorfulPointyAndASlantedRoof_04.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Then translate the steps into code
1212
// Make sure to run after each line
1313
//
14-
public class HousesToAColorfulPointyAndASlantedRoof_05
14+
public class HousesToAColorfulPointyAndASlantedRoof_04
1515
{
1616
public static void main(String[] args)
1717
{

src/main/java/org/teachingkidsprogramming/recipes/completed/section02methods/PyramidsOfGizaMiddle.java renamed to src/main/java/org/teachingkidsprogramming/recipes/completed/section02methods/KataQuestions/PyramidsOfGizaRemoveDuplication_01.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
package org.teachingkidsprogramming.recipes.completed.section02methods;
1+
package org.teachingkidsprogramming.recipes.completed.section02methods.KataQuestions;
22

33
import org.teachingextensions.logo.Tortoise;
44
// NOTE: Re-factor to remove duplicate code HINT: Use Extract Method
55
import org.teachingextensions.logo.utils.ColorUtils.PenColors;
66

7-
public class PyramidsOfGizaMiddle
7+
//------------Kata Question---------------//
8+
// Where do you see duplicate lines of code?
9+
// and how can you refactor to make this code more readable?
10+
// Write out the steps in English
11+
// Then translate the steps into code
12+
// Make sure to run after each line
13+
//
14+
public class PyramidsOfGizaRemoveDuplication_01
815
{
916
public static void main(String[] args) throws Exception
1017
{

src/main/java/org/teachingkidsprogramming/recipes/completed/section02methods/PyramidsOfGizaEnd.java renamed to src/main/java/org/teachingkidsprogramming/recipes/completed/section02methods/KataQuestions/PyramidsOfGizaRemoveEvenMoreDuplication_03.java

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

33
import org.teachingextensions.logo.Tortoise;
44
import org.teachingextensions.logo.utils.ColorUtils.PenColors;
55

6-
public class PyramidsOfGizaEnd
6+
//------------Kata Question---------------//
7+
//Where do you see duplicate lines of code?
8+
// and how can you refactor to make this code more readable?
9+
//Write out the steps in English
10+
//Then translate the steps into code
11+
//Make sure to run after each line
12+
//
13+
public class PyramidsOfGizaRemoveEvenMoreDuplication_03
714
{
815
public static void main(String[] args) throws Exception
916
{
@@ -17,7 +24,6 @@ public static void main(String[] args) throws Exception
1724
moveDown();
1825
turnAndMove(135, 210);
1926
}
20-
// this makes the turtle turn and move -- duh
2127
public static void turnAndMove(int degrees, int length)
2228
{
2329
Tortoise.turn(degrees);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.teachingkidsprogramming.recipes.completed.section02methods.KataQuestions;
2+
3+
import org.teachingextensions.logo.Tortoise;
4+
// NOTE: Re-factor to remove duplicate code HINT: Use Extract Method
5+
import org.teachingextensions.logo.utils.ColorUtils.PenColors;
6+
7+
//------------Kata Question---------------//
8+
// Where do you see duplicate lines of code?
9+
// and how can you refactor to make this code more readable?
10+
// Write out the steps in English
11+
// Then translate the steps into code
12+
// Make sure to run after each line
13+
//
14+
public class PyramidsOfGizaRemoveMoreDuplication_02
15+
{
16+
public static void main(String[] args) throws Exception
17+
{
18+
setUpPyramidLand();
19+
Tortoise.turn(-90);
20+
Tortoise.move(220);
21+
Tortoise.turn(135);
22+
Tortoise.move(100);
23+
moveDown();
24+
Tortoise.turn(-90);
25+
Tortoise.move(100);
26+
moveDown();
27+
Tortoise.turn(-90);
28+
Tortoise.move(100);
29+
moveDown();
30+
Tortoise.turn(135);
31+
Tortoise.move(210);
32+
}
33+
public static void moveDown()
34+
{
35+
Tortoise.turn(90);
36+
Tortoise.move(100);
37+
}
38+
private static void setUpPyramidLand()
39+
{
40+
Tortoise.show();
41+
Tortoise.setSpeed(10);
42+
Tortoise.getBackgroundWindow().setBackground(PenColors.Blues.AliceBlue);
43+
Tortoise.setPenColor(PenColors.Yellows.DarkGoldenrod);
44+
Tortoise.setPenWidth(2);
45+
Tortoise.hide();
46+
}
47+
}

0 commit comments

Comments
 (0)