From d106ce804e1a2924d8a58a73f393e4ee79112560 Mon Sep 17 00:00:00 2001 From: Sahil-Patel Date: Mon, 25 Jan 2016 12:20:28 -0600 Subject: [PATCH 1/3] Completed Houses Quiz --- .../section02methods/HousesQuiz.java | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/section02methods/HousesQuiz.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/section02methods/HousesQuiz.java index 49dc43d3..94f3c61b 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/section02methods/HousesQuiz.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/section02methods/HousesQuiz.java @@ -26,26 +26,19 @@ public void questions1Thru6() // ------------- Recipe for large // set the current length to 63 large(); - // ------------- End of large recipe - // - // Question4 - // moveTheLength (recipe below) - // ------------- Recipe for moveTheLength - // move the Tortoise the current length - moveTheLength(); - // ------------- End of moveTheLength recipe - // - // Question5 - // turnTheCorner (recipe below) - // ------------- Recipe for turnTheCorner - // turn the Tortoise 1/3 of 360 degrees to the left - turnTheCorner(); + drawASide(); // ------------- End of turnTheCorner recipe // // Question6 // drawASide (recipe below) + drawASide(); + } + private void drawASide() + { // ------------- Recipe for drawASide // call moveTheLength and turnTheCorner + moveTheLength(); + turnTheCorner(); // ------------- End of drawASide recipe } private void turnTheCorner() From c165f301a5452c7a1a3f480c7880637ffecc4798 Mon Sep 17 00:00:00 2001 From: Sahil-Patel Date: Mon, 25 Jan 2016 12:32:32 -0600 Subject: [PATCH 2/3] working on triangle shell --- .../section02methods/TriangleShell.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/section02methods/TriangleShell.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/section02methods/TriangleShell.java index c9fda2ac..66be54b3 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/section02methods/TriangleShell.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/section02methods/TriangleShell.java @@ -1,5 +1,6 @@ package org.teachingkidsprogramming.section02methods; +import org.teachingextensions.logo.Tortoise; @SuppressWarnings("unused") public class TriangleShell @@ -8,20 +9,31 @@ public class TriangleShell public static void main(String[] args) { // Show the tortoise --#1 + Tortoise.show(); + int currentLength = 50; // Make the tortoise go as fast as possible --#6 // Do the following 60 times --#7.1 // Change the pen color of the line the tortoise draws to a random color --#9 // Increase the current length of the side by 4 pixels --#8 // drawTriangle (recipe below) --#5.1 // - // ------------- Recipe for drawTriangle --#5.2 - // Do the following 3 times --#3.1 - // Move the tortoise using the current length --#4 - // Turn the tortoise 1/3rd of 360 degrees --#2 - // Repeat --#3.2 - // ------------- End of drawTriangle recipe --#5.3 + drawTriangle(currentLength); // // Turn the tortoise 1/60th of 360 degrees to the right --#10 // Repeat --#7.2 } + private static void drawTriangle(int currentLength) + { + // ------------- Recipe for drawTriangle --#5.2 + // Do the following 3 times --#3.1 + for (int i = 0; i < 3; i++) + { + // Move the tortoise using the current length --#4 + Tortoise.move(currentLength); + // Turn the tortoise 1/3rd of 360 degrees --#2 + Tortoise.turn(360 / 3); + } + // Repeat --#3.2 + // ------------- End of drawTriangle recipe --#5.3 + } } From 53a049f3ebd5797618a5f87eb5f3073f31c0ac32 Mon Sep 17 00:00:00 2001 From: Sahil-Patel Date: Mon, 25 Jan 2016 12:52:33 -0600 Subject: [PATCH 3/3] Completed TriangleShell.java --- .../section02methods/TriangleShell.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/section02methods/TriangleShell.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/section02methods/TriangleShell.java index 66be54b3..7a829998 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/section02methods/TriangleShell.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/section02methods/TriangleShell.java @@ -1,6 +1,7 @@ package org.teachingkidsprogramming.section02methods; import org.teachingextensions.logo.Tortoise; +import org.teachingextensions.logo.utils.ColorUtils.PenColors; @SuppressWarnings("unused") public class TriangleShell @@ -12,15 +13,22 @@ public static void main(String[] args) Tortoise.show(); int currentLength = 50; // Make the tortoise go as fast as possible --#6 + Tortoise.setSpeed(10); // Do the following 60 times --#7.1 - // Change the pen color of the line the tortoise draws to a random color --#9 - // Increase the current length of the side by 4 pixels --#8 - // drawTriangle (recipe below) --#5.1 - // - drawTriangle(currentLength); - // - // Turn the tortoise 1/60th of 360 degrees to the right --#10 - // Repeat --#7.2 + for (int i = 0; i < 60; i++) + { + // Change the pen color of the line the tortoise draws to a random color --#9 + Tortoise.setPenColor(PenColors.getRandomColor()); + // Increase the current length of the side by 4 pixels --#8 + currentLength = currentLength + 4; + // drawTriangle (recipe below) --#5.1 + // + drawTriangle(currentLength); + // + // Turn the tortoise 1/60th of 360 degrees to the right --#10 + Tortoise.turn(360 / 60); + // Repeat --#7.2 + } } private static void drawTriangle(int currentLength) {