File tree Expand file tree Collapse file tree
src/main/java/org/teachingkidsprogramming Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ package org .teachingkidsprogramming .section02methods ;
2+
3+ import org .teachingextensions .logo .Tortoise ;
4+ import org .teachingextensions .logo .utils .ColorUtils .PenColors ;
5+
6+ public class PyramidsOfGiza
7+ {
8+ public static void main (String [] args ) throws Exception
9+ {
10+ setUpPyramidLand ();
11+ // Turn the tortoise 90 degrees to the left
12+ // Move the tortoise 220 pixels
13+ // Turn the tortoise 135 degrees to the right
14+ // Move the tortoise 100 pixels
15+ // Turn the tortoise 90 degrees to the right
16+ // Move the tortoise 100 pixels
17+ // Turn the tortoise 90 degrees to the left
18+ // Move the tortoise 100 pixels
19+ // Turn the tortoise 90 degrees to the right
20+ // Move the tortoise 100 pixels
21+ // Turn the tortoise 90 degrees to the left
22+ // Move the tortoise 100 pixels
23+ // Turn the tortoise 90 degrees to the right
24+ // Move the tortoise 100 pixels
25+ // Turn the tortoise 135 degrees to the right
26+ // Move the tortoise 210 pixels
27+ }
28+ private static void setUpPyramidLand ()
29+ {
30+ Tortoise .show ();
31+ Tortoise .setSpeed (10 );
32+ Tortoise .getBackgroundWindow ().setBackground (PenColors .Blues .AliceBlue );
33+ Tortoise .setPenColor (PenColors .Yellows .DarkGoldenrod );
34+ Tortoise .setPenWidth (2 );
35+ Tortoise .hide ();
36+ }
37+ }
Original file line number Diff line number Diff line change 1- package org .teachingkidsprogramming .recipes . inDevelopment ;
1+ package org .teachingkidsprogramming .section02methods ;
22
33import org .teachingextensions .logo .Tortoise ;
4+ import org .teachingextensions .logo .utils .ColorUtils .PenColors ;
45
5- public class PyramidsOfGiza
6+ public class PyramidsOfGizaEnd
67{
7- /*----IN PROGRESS-----------------------------------*/
88 public static void main (String [] args ) throws Exception
99 {
10- Tortoise .show ();
11- Tortoise .setSpeed (10 );
10+ setUpPyramidLand ();
1211 turnAndMove (-90 , 220 );
1312 turnAndMove (135 , 100 );
1413 moveDown ();
1514 moveUp ();
1615 moveDown ();
1716 moveUp ();
1817 moveDown ();
19- Tortoise .turn (135 );
20- Tortoise .move (210 );
18+ turnAndMove (135 , 210 );
19+ }
20+ public static void turnAndMove (int degrees , int length )
21+ {
22+ Tortoise .turn (degrees );
23+ Tortoise .move (length );
2124 }
2225 public static void moveDown ()
2326 {
@@ -27,9 +30,13 @@ public static void moveUp()
2730 {
2831 turnAndMove (-90 , 100 );
2932 }
30- public static void turnAndMove ( int degrees , int length )
33+ private static void setUpPyramidLand ( )
3134 {
32- Tortoise .turn (degrees );
33- Tortoise .move (length );
35+ Tortoise .show ();
36+ Tortoise .setSpeed (10 );
37+ Tortoise .getBackgroundWindow ().setBackground (PenColors .Blues .AliceBlue );
38+ Tortoise .setPenColor (PenColors .Yellows .DarkGoldenrod );
39+ Tortoise .setPenWidth (2 );
40+ Tortoise .hide ();
3441 }
3542}
Original file line number Diff line number Diff line change 1- package org .teachingkidsprogramming .recipes . inDevelopment ;
1+ package org .teachingkidsprogramming .section02methods ;
22
33import org .teachingextensions .logo .Tortoise ;
4+ // NOTE: Re-factor to remove duplicate code HINT: Use Extract Method
5+ import org .teachingextensions .logo .utils .ColorUtils .PenColors ;
46
5- public class PyramidsOfGizaStarter
7+ public class PyramidsOfGizaMiddle
68{
7- /*----IN PROGRESS-----------------------------------*/
89 public static void main (String [] args ) throws Exception
910 {
10- // Show the tortoise
11- Tortoise .show ();
12- Tortoise .setSpeed (10 );
11+ setUpPyramidLand ();
1312 Tortoise .turn (-90 );
1413 Tortoise .move (220 );
1514 Tortoise .turn (135 );
@@ -27,13 +26,13 @@ public static void main(String[] args) throws Exception
2726 Tortoise .turn (135 );
2827 Tortoise .move (210 );
2928 }
29+ private static void setUpPyramidLand ()
30+ {
31+ Tortoise .show ();
32+ Tortoise .setSpeed (10 );
33+ Tortoise .getBackgroundWindow ().setBackground (PenColors .Blues .AliceBlue );
34+ Tortoise .setPenColor (PenColors .Yellows .DarkGoldenrod );
35+ Tortoise .setPenWidth (2 );
36+ Tortoise .hide ();
37+ }
3038}
31- /*
32- // Show the tortoise --#1
33- // Make the tortoise move as fast as possible --#6
34- // Do the following 4 times --#5.1
35- // Change the pen color of the line the tortoise draws to blue --#4
36- // Move the tortoise 50 pixels --#2
37- // Turn the tortoise to the right (90 degrees) --#3
38- // Repeat --#5.2
39- */
You can’t perform that action at this time.
0 commit comments