File tree Expand file tree Collapse file tree 4 files changed +166
-7
lines changed
src/main/java/org/teachingkidsprogramming/recipes/completed/section02methods/KataQuestions Expand file tree Collapse file tree 4 files changed +166
-7
lines changed Original file line number Diff line number Diff line change 1+ package org .teachingkidsprogramming .recipes .completed .section02methods .KataQuestions ;
2+
3+ import org .teachingextensions .logo .Tortoise ;
4+ import org .teachingextensions .logo .utils .ColorUtils .PenColors ;
5+
6+ //------------Kata Question---------------//
7+ // How would you make a pointy roof
8+ // and how would make a slanted roof
9+ // and change the color of the houses?
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 HousesToAColorfulPointyAndASlantedRoof_05
15+ {
16+ public static void main (String [] args )
17+ {
18+ Tortoise .show ();
19+ Tortoise .setSpeed (10 );
20+ Tortoise .setX (200 );
21+ int height = 40 ;
22+ drawSlantedRoofHouse (height );
23+ drawPointyRoofHouse (120 );
24+ drawSlantedRoofHouse (90 );
25+ drawPointyRoofHouse (20 );
26+ }
27+ public static void drawSlantedRoofHouse (int height )
28+ {
29+ Tortoise .setPenColor (PenColors .Grays .LightGray );
30+ Tortoise .move (height );
31+ drawSlantedRoof ();
32+ Tortoise .move (height );
33+ Tortoise .turn (-90 );
34+ Tortoise .move (20 );
35+ Tortoise .turn (-90 );
36+ }
37+ private static void drawSlantedRoof ()
38+ {
39+ Tortoise .turn (45 );
40+ Tortoise .move (60 );
41+ Tortoise .turn (135 );
42+ Tortoise .move (45 );
43+ }
44+ public static void drawPointyRoofHouse (int height )
45+ {
46+ Tortoise .setPenColor (PenColors .Grays .LightGray );
47+ Tortoise .move (height );
48+ drawPointyRoof ();
49+ Tortoise .move (height );
50+ Tortoise .turn (-90 );
51+ Tortoise .move (20 );
52+ Tortoise .turn (-90 );
53+ }
54+ private static void drawPointyRoof ()
55+ {
56+ Tortoise .turn (45 );
57+ Tortoise .move (30 );
58+ Tortoise .turn (90 );
59+ Tortoise .move (30 );
60+ Tortoise .turn (45 );
61+ }
62+ }
Original file line number Diff line number Diff line change 1+ package org .teachingkidsprogramming .recipes .completed .section02methods .KataQuestions ;
2+
3+ import org .teachingextensions .logo .Tortoise ;
4+ import org .teachingextensions .logo .utils .ColorUtils .PenColors ;
5+
6+ //------------Kata Question---------------//
7+ // How would you make a pointy roof
8+ // and how would make a slanted roof?
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 HousesToAPointyAndASlantedRoof_03
14+ {
15+ public static void main (String [] args )
16+ {
17+ Tortoise .show ();
18+ Tortoise .setSpeed (10 );
19+ Tortoise .setX (200 );
20+ int height = 40 ;
21+ drawHouse (height );
22+ drawHouse (120 );
23+ drawHouse (90 );
24+ drawHouse (20 );
25+ }
26+ public static void drawHouse (int height )
27+ {
28+ Tortoise .setPenColor (PenColors .Grays .LightGray );
29+ Tortoise .move (height );
30+ drawSlantedRoof ();
31+ Tortoise .move (height );
32+ Tortoise .turn (-90 );
33+ Tortoise .move (20 );
34+ Tortoise .turn (-90 );
35+ }
36+ private static void drawSlantedRoof ()
37+ {
38+ Tortoise .turn (45 );
39+ Tortoise .move (60 );
40+ Tortoise .turn (135 );
41+ Tortoise .move (45 );
42+ }
43+ private static void drawPointyRoof ()
44+ {
45+ Tortoise .turn (45 );
46+ Tortoise .move (30 );
47+ Tortoise .turn (90 );
48+ Tortoise .move (30 );
49+ Tortoise .turn (45 );
50+ }
51+ }
Original file line number Diff line number Diff line change 1- package org .teachingkidsprogramming .recipes .completed .section02methods ;
1+ package org .teachingkidsprogramming .recipes .completed .section02methods . KataQuestions ;
22
33import org .teachingextensions .logo .Tortoise ;
44import org .teachingextensions .logo .utils .ColorUtils .PenColors ;
55
6- //
76//------------Kata Question---------------//
8- // How would you make a slanted roof?
7+ // How would you make a pointy roof?
98// Write out the steps in English
109// Then translate the steps into code
1110// Make sure to run after each line
1211//
13- public class HousesKataQuestion
12+ public class HousesToAPointyRoof_01
1413{
1514 public static void main (String [] args )
1615 {
@@ -27,12 +26,16 @@ public static void drawHouse(int height)
2726 {
2827 Tortoise .setPenColor (PenColors .Grays .LightGray );
2928 Tortoise .move (height );
30- Tortoise .turn (90 );
31- Tortoise .move (30 );
32- Tortoise .turn (90 );
29+ drawRoof ();
3330 Tortoise .move (height );
3431 Tortoise .turn (-90 );
3532 Tortoise .move (20 );
3633 Tortoise .turn (-90 );
3734 }
35+ private static void drawRoof ()
36+ {
37+ Tortoise .turn (90 );
38+ Tortoise .move (30 );
39+ Tortoise .turn (90 );
40+ }
3841}
Original file line number Diff line number Diff line change 1+ package org .teachingkidsprogramming .recipes .completed .section02methods .KataQuestions ;
2+
3+ import org .teachingextensions .logo .Tortoise ;
4+ import org .teachingextensions .logo .utils .ColorUtils .PenColors ;
5+
6+ //------------Kata Question---------------//
7+ // How would you make a slanted roof?
8+ // Write out the steps in English
9+ // Then translate the steps into code
10+ // Make sure to run after each line
11+ //
12+ public class HousesToASlantedRoof_02
13+ {
14+ public static void main (String [] args )
15+ {
16+ Tortoise .show ();
17+ Tortoise .setSpeed (10 );
18+ Tortoise .setX (200 );
19+ int height = 40 ;
20+ drawHouse (height );
21+ drawHouse (120 );
22+ drawHouse (90 );
23+ drawHouse (20 );
24+ }
25+ public static void drawHouse (int height )
26+ {
27+ Tortoise .setPenColor (PenColors .Grays .LightGray );
28+ Tortoise .move (height );
29+ drawPointyRoof ();
30+ Tortoise .move (height );
31+ Tortoise .turn (-90 );
32+ Tortoise .move (20 );
33+ Tortoise .turn (-90 );
34+ }
35+ private static void drawPointyRoof ()
36+ {
37+ Tortoise .turn (45 );
38+ Tortoise .move (30 );
39+ Tortoise .turn (90 );
40+ Tortoise .move (30 );
41+ Tortoise .turn (45 );
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments