Skip to content

Commit 71b499b

Browse files
committed
added PyramidsOfGiza starter recipe
1 parent 9580caa commit 71b499b

2 files changed

Lines changed: 26 additions & 9 deletions

File tree

src/main/java/org/teachingkidsprogramming/recipes/inDevelopment/PyramidsOfGiza.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
package org.teachingkidsprogramming.recipes.inDevelopment;
22

33
import org.teachingextensions.logo.Tortoise;
4-
// NOTE: this might need to be broken into several different recipes??
5-
// e.g. PyramidsOfGiza01, PyramidsOfGiza02, PyramidsOfGiza03, etc...
6-
// This is a very simple/basic recipe introducing passing multiple values
7-
// into methods and reinforcing basic refactoring.
8-
// This can be completed in several 'passes' or 'steps of refactoring' as follows:
94
//
10-
// 1. entire recipe written in linear fashion with lots of repeated code
5+
// 1. This recipe written in linear fashion with lots of repeated code
116
// 2. a) turnAndMove() method created
127
// b) every 2 linear turn() and move() calls are replaced by 1 call to new turnAndMove() method
138
// 3. Now another pattern emerges, and a 3rd refactoring/abstraction takes place
149
// when the student notices that there are several each of
15-
// turnAndMove(90, 100) & turnAndMove(-90, 100), so 2 new methods are written:
16-
// turnAndMove(90, 100) becomes -> moveDown() & turnAndMove(-90, 100) -> moveUp()
10+
// turnAndMove(90, 100) & turnAndMove(-90, 100), so 2 new methods are written:
11+
// turnAndMove(90, 100) becomes -> moveDown() & turnAndMove(-90, 100) -> moveUp()
1712
// 4. At this point, students are encouraged to see if there might be any other possible patterns
1813
// to refactor
1914

20-
// Where to add? In Course 1 or Course 2 - concepts taught: refactoring
15+
// Where to add? In Course 1 or Course 2 - concepts taught: method arguments (variables) and refactoring
2116
public class PyramidsOfGiza
2217
{
2318
public static void main(String[] args) throws Exception
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.teachingkidsprogramming.recipes.inDevelopment;
2+
3+
import org.teachingextensions.logo.Tortoise;
4+
5+
public class PyramidsOfGizaStarter
6+
{
7+
public static void main(String[] args) throws Exception
8+
{
9+
setupTortoise();
10+
// USER STORY: Write the code to draw 3 pyramids
11+
// Draw a sketch
12+
// Write out each step in English
13+
// Write the code one line at a time
14+
// Run your program to verify that your code works
15+
// Remove duplicate code by using the 'extract method' re-factoring
16+
}
17+
private static void setupTortoise()
18+
{
19+
Tortoise.show();
20+
Tortoise.setSpeed(10);
21+
}
22+
}

0 commit comments

Comments
 (0)