From d043ecee736e8ae9f30ee173537311f7f241247e Mon Sep 17 00:00:00 2001 From: Peter Duong <19duong96@gmail.com> Date: Wed, 19 Jun 2013 14:45:07 -0700 Subject: [PATCH 1/4] finished homework- Peter and Hailey --- .../recipes/homework/Homework01.java | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/homework/Homework01.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/homework/Homework01.java index ee1f46c1..bddd70b0 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/homework/Homework01.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/homework/Homework01.java @@ -3,13 +3,11 @@ import junit.framework.Assert; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.teachingextensions.logo.Tortoise; import org.teachingextensions.logo.Turtle; import org.teachingextensions.logo.utils.TortoiseUtils; - public class Homework01 { // 'How to do homework: @@ -24,54 +22,54 @@ public class Homework01 @Test public void numbersDoNotNeedQuotes() { - Assert.assertEquals(42, ____); + Assert.assertEquals(42, 42); } @Test public void defaultWidthForTheTortoise() throws Exception { - Assert.assertEquals(Tortoise.getPenWidth(), ____); + Assert.assertEquals(Tortoise.getPenWidth(), 2); } @Test public void stringsNeedQuotes() throws Exception { - Assert.assertEquals("Green", ___); + Assert.assertEquals("Green", "Green"); } @Test public void stringsCanIncludeSpaces() throws Exception { - Assert.assertEquals("This is a string", ___); + Assert.assertEquals("This is a string", "This is a string"); } @Test public void changingThePenWidthTo5() throws Exception { - Tortoise.setPenWidth(____); + Tortoise.setPenWidth(5); Assert.assertEquals(5, Tortoise.getPenWidth()); } @Test public void movingTheTortoise100Pixels() throws Exception { int start = Tortoise.getY(); - Tortoise.move(____); + Tortoise.move(100); Assert.assertEquals(Tortoise.getY(), start - 100); // 'Hint: make sure you read the name of this method } @Test public void theTortoiseTurns21() throws Exception { - Tortoise.turn(____); + Tortoise.turn(21.0); Assert.assertEquals(21.0, Tortoise.getAngle()); } @Test public void theTortoiseTurns15Twice() throws Exception { - Tortoise.turn(____); - Tortoise.turn(____); + Tortoise.turn(15.0); + Tortoise.turn(15.0); Assert.assertEquals(30.0, Tortoise.getAngle()); } @Test public void howFastCanTheTortoiseGo() throws Exception { - Tortoise.setSpeed(____); + Tortoise.setSpeed(10); Assert.assertEquals(Tortoise.getSpeed(), topSpeed); // 'Hint: Click SetSpeed then read the documentation on the left -----> } @@ -79,25 +77,25 @@ public void howFastCanTheTortoiseGo() throws Exception public void assigningVariables() throws Exception { int myFavoriteNumber = 101; - Assert.assertEquals(myFavoriteNumber, ____); + Assert.assertEquals(myFavoriteNumber, 101); } @Test public void combiningNumbers() throws Exception { int age = 3 + 4; - Assert.assertEquals(age, ____); + Assert.assertEquals(age, 7); } @Test public void combiningText() throws Exception { String name = "Peter" + " " + "Pan"; - Assert.assertEquals(name, ___); + Assert.assertEquals(name, "Peter Pan"); } @Test public void combiningTextAndNumbers() throws Exception { String name = "Henry The " + 8; - Assert.assertEquals(name, ___); + Assert.assertEquals(name, "Henry The 8"); } @Test public void combiningTextInALoop() throws Exception @@ -107,13 +105,13 @@ public void combiningTextInALoop() throws Exception { sound += "H"; } - Assert.assertEquals(sound, ___); + Assert.assertEquals(sound, "AHHH"); } @Test public void forLoopsEndAtTheEnd() throws Exception { String numbers = "# "; - for (int i = 1; i <= ____; i++) + for (int i = 1; i <= 5; i++) { numbers += i; preventInfiniteLoops(); @@ -124,7 +122,7 @@ public void forLoopsEndAtTheEnd() throws Exception public void forLoopsCanStartAnywhere() throws Exception { String answer = "Because "; - for (int i = ____; i <= 9; i++) + for (int i = 7; i <= 9; i++) { answer += i; preventInfiniteLoops(); @@ -136,7 +134,7 @@ public void forLoopsCanStartAnywhere() throws Exception public void forLoopsCanSkip() throws Exception { String numbers = "# "; - for (int i = 1; i <= 20; i += ____) + for (int i = 1; i <= 20; i += 2) { numbers = numbers + i + ","; preventInfiniteLoops(); @@ -147,7 +145,7 @@ public void forLoopsCanSkip() throws Exception public void forLoopsCanSkipUpAndDown() throws Exception { String numbers = "# "; - for (int i = 20; 0 < i && i <= 40; i += ____) + for (int i = 20; 0 < i && i <= 40; i += -3) { numbers = numbers + i + ","; preventInfiniteLoops(); @@ -158,7 +156,7 @@ public void forLoopsCanSkipUpAndDown() throws Exception public void forLoopsCanGoBackwards() throws Exception { String numbers = "Countdown: "; - for (int i = 9; i >= 1; i += ____) + for (int i = 9; i >= 1; i += -1) { numbers += i; preventInfiniteLoops(); From 8f880e5bcea7788f3dea49c69c4a726891af5482 Mon Sep 17 00:00:00 2001 From: Peter Duong <19duong96@gmail.com> Date: Wed, 19 Jun 2013 15:04:31 -0700 Subject: [PATCH 2/4] Houses Phuoc Hailey --- .../recipes/Houses.java | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java index 16c8cb93..2d0ab8c4 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java @@ -1,26 +1,31 @@ package org.teachingkidsprogramming.recipes; +import org.teachingextensions.logo.Colors; +import org.teachingextensions.logo.Tortoise; + public class Houses { public static void main(String[] args) { - // Make the tortoise move as fast as possible --#11 - // Have the tortoise start at 200 pixels in on the X axis --#14 - // The current height is 40 --#1.2 - // drawHouse (recipe below) --#9 - // ------------- Recipe for drawHouse --#9 + Tortoise.setSpeed(10); + Tortoise.setX(200); + int height = 40; + drawHouse(height); + drawHouse(120); + drawHouse(90); + drawHouse(20); + } + private static void drawHouse(int height) + { // Change the color of the line the tortoise draws to lightGray --#15 - // Move the tortoise the height of a house --#1.1 - // Turn the tortoise 90 degrees to the right --#2 - // Move the tortoise 30 pixels --#3 - // Turn the tortoise 90 degrees to the right --#4 - // Move the tortoise the height of a house --#5 - // Turn the tortoise 90 degrees to the left --#6 - // Move the tortoise 20 pixels --#7 - // Turn the tortoise 90 degrees to the left --#8 - // ------------- End of drawHouse recipe - // DrawHouse with height 120 (recipe below) --#10 - // DrawHouse with height 90 (recipe below) --#12 - // DrawHouse with height 20 (recipe below) --#13 + Tortoise.setPenColor(Colors.Grays.LightGray); + Tortoise.move(height); + Tortoise.turn(90); + Tortoise.move(30); + Tortoise.turn(90); + Tortoise.move(height); + Tortoise.turn(-90); + Tortoise.move(20); + Tortoise.turn(-90); } } From 5bc253d0241b4ce8198a169ae7b6c4799caddc3f Mon Sep 17 00:00:00 2001 From: Peter Duong <19duong96@gmail.com> Date: Wed, 19 Jun 2013 15:48:17 -0700 Subject: [PATCH 3/4] houses M phuoc hailey --- .../recipes/Houses.java | 51 +++++++++++++++---- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java index 2d0ab8c4..42b41d45 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java @@ -1,5 +1,7 @@ package org.teachingkidsprogramming.recipes; +import java.awt.Color; + import org.teachingextensions.logo.Colors; import org.teachingextensions.logo.Tortoise; @@ -10,22 +12,53 @@ public static void main(String[] args) Tortoise.setSpeed(10); Tortoise.setX(200); int height = 40; - drawHouse(height); - drawHouse(120); - drawHouse(90); - drawHouse(20); + drawHouse(height, Colors.Grays.LightGray); + drawHouse(120, Colors.Grays.LightGray); + drawHouse(90, Colors.Grays.LightGray); + drawHouse(20, Colors.Grays.LightGray); } - private static void drawHouse(int height) + private static void drawHouse(int height, Color color) { - // Change the color of the line the tortoise draws to lightGray --#15 - Tortoise.setPenColor(Colors.Grays.LightGray); + Tortoise.setPenColor(color); Tortoise.move(height); + // flatRoof(); + //amittasisRoof(); + //MavericksRoof + //turn Left 90 + Tortoise.turn(-90); + //move 10 + Tortoise.move(10); + //turn right 90+45 + Tortoise.turn(90 + 45); + //move 50 + Tortoise.move(50); + //turn 90 Tortoise.turn(90); - Tortoise.move(30); - Tortoise.turn(90); + // move 50 + Tortoise.move(50); + // turn 90 + 45 + Tortoise.turn(90 + 45); + // move 10 + Tortoise.move(10); + // turn 90 left + Tortoise.turn(-90); Tortoise.move(height); Tortoise.turn(-90); Tortoise.move(20); Tortoise.turn(-90); } + private static void amittasisRoof() + { + Tortoise.turn(45); + Tortoise.move(10); + Tortoise.turn(90); + Tortoise.move(10); + Tortoise.turn(45); + } + private static void flatRoof() + { + Tortoise.turn(90); + Tortoise.move(30); + Tortoise.turn(90); + } } From 3e6f33c530f97fe04f231952d4ea12b52132cd60 Mon Sep 17 00:00:00 2001 From: Peter Duong <19duong96@gmail.com> Date: Wed, 19 Jun 2013 16:02:10 -0700 Subject: [PATCH 4/4] Houses quiz phuoc and Hailey --- .../recipes/Houses.java | 21 +++---- .../recipes/quizzes/HousesQuiz.java | 56 +++++++++++-------- 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java index 42b41d45..db99e32d 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java @@ -24,27 +24,22 @@ private static void drawHouse(int height, Color color) // flatRoof(); //amittasisRoof(); //MavericksRoof - //turn Left 90 + mavericksRoof(); + Tortoise.move(height); + Tortoise.turn(-90); + Tortoise.move(20); + Tortoise.turn(-90); + } + private static void mavericksRoof() + { Tortoise.turn(-90); - //move 10 Tortoise.move(10); - //turn right 90+45 Tortoise.turn(90 + 45); - //move 50 Tortoise.move(50); - //turn 90 Tortoise.turn(90); - // move 50 Tortoise.move(50); - // turn 90 + 45 Tortoise.turn(90 + 45); - // move 10 Tortoise.move(10); - // turn 90 left - Tortoise.turn(-90); - Tortoise.move(height); - Tortoise.turn(-90); - Tortoise.move(20); Tortoise.turn(-90); } private static void amittasisRoof() diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/HousesQuiz.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/HousesQuiz.java index 5939a3b5..0fa481fa 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/HousesQuiz.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/HousesQuiz.java @@ -1,37 +1,49 @@ package org.teachingkidsprogramming.recipes.quizzes; +import org.teachingextensions.logo.Tortoise; import org.teachingkidsprogramming.recipes.quizzes.graders.HousesQuizGrader; public class HousesQuiz extends org.teachingkidsprogramming.recipes.quizzes.graders.HousesQuiz { public void question1() { - // The current length is 7 + length = 7; + } + @Override + public void medium() + { + super.medium(); + length = 21; + } + @Override + public void large() + { + super.large(); + length = 63; + } + @Override + public void moveTheLength() + { + super.moveTheLength(); + Tortoise.move(length); + } + @Override + public void turnTheCorner() + { + super.turnTheCorner(); + Tortoise.turn(-360 / 3); } - // - // Question2 - // Create a method called medium - // that sets the current length to 21 - // - // - // Question3 - // Create a method called large - // that sets the current length to 63 - // - // - // Question4 - // Create a method called moveTheLength - // that moves the Tortoise the current length - // - // - // Question5 - // Create a method called turnTheCorner - // that turns the Tortoise 1/3 of 360 degrees to the left - // - // // Question6 // Create a method called drawASide // that calls moveTheLength and turnTheCorner + @Override + public void drawASide() + { + // TODO Auto-generated method stub + super.drawASide(); + moveTheLength(); + turnTheCorner(); + } // public static void main(String[] args) {