From 8c979522192586d32390a4060a1156b48cd30521 Mon Sep 17 00:00:00 2001 From: Sydney Kusumoputro Date: Wed, 19 Jun 2013 14:45:57 -0700 Subject: [PATCH 01/13] homework 1 commit- Sydney (Amittai up front) --- .../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..5f6e6b28 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); Assert.assertEquals(21.0, Tortoise.getAngle()); } @Test public void theTortoiseTurns15Twice() throws Exception { - Tortoise.turn(____); - Tortoise.turn(____); + Tortoise.turn(15); + Tortoise.turn(15); 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 54d830df532af4cda2c7d4360b937b41b3a8feba Mon Sep 17 00:00:00 2001 From: Sydney Kusumoputro Date: Wed, 19 Jun 2013 15:22:20 -0700 Subject: [PATCH 02/13] final houses Sydney and Amittai --- .../recipes/Houses.java | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java index 16c8cb93..3568bdc2 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java @@ -1,26 +1,32 @@ package org.teachingkidsprogramming.recipes; +import java.awt.Color; + +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 - // 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.setX(200); + int height = 40; + drawHouse(height); + drawHouse(120); + drawHouse(90); + drawHouse(20); + } + private static void drawHouse(int height) + { + Tortoise.setPenColor(Color.gray.lightGray); + Tortoise.setSpeed(10); + Tortoise.hide(); + 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 23f0801918225584e39fe193482739995e1e333b Mon Sep 17 00:00:00 2001 From: Sydney Kusumoputro Date: Wed, 19 Jun 2013 15:42:59 -0700 Subject: [PATCH 03/13] Amittai's roof success Sydney Amittai --- .../recipes/Houses.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java index 3568bdc2..8c817e73 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/Houses.java @@ -2,6 +2,7 @@ import java.awt.Color; +import org.teachingextensions.logo.Colors; import org.teachingextensions.logo.Tortoise; public class Houses @@ -17,16 +18,34 @@ public static void main(String[] args) } private static void drawHouse(int height) { - Tortoise.setPenColor(Color.gray.lightGray); + Tortoise.setPenColor(colorChooser()); Tortoise.setSpeed(10); Tortoise.hide(); Tortoise.move(height); + //flatRoof(); + //AmittaisRoof; + Tortoise.turn(45); + //move 10 + Tortoise.move(10); + //turn 90 right Tortoise.turn(90); - Tortoise.move(30); - Tortoise.turn(90); + //move 10 + Tortoise.move(10); + //turn 60 + Tortoise.turn(45); Tortoise.move(height); Tortoise.turn(-90); Tortoise.move(20); Tortoise.turn(-90); } + private static void flatRoof() + { + Tortoise.turn(90); + Tortoise.move(30); + Tortoise.turn(90); + } + private static Color colorChooser() + { + return Colors.Grays.LightGray; + } } From 770320297b5f83a4b0f118dbd2228f9334adcccf Mon Sep 17 00:00:00 2001 From: Sydney Kusumoputro Date: Thu, 20 Jun 2013 12:58:33 -0700 Subject: [PATCH 04/13] House Quiz Amittai and Sydney --- .../recipes/quizzes/HousesQuiz.java | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/HousesQuiz.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/HousesQuiz.java index 5939a3b5..62d286dd 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/HousesQuiz.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/HousesQuiz.java @@ -1,38 +1,40 @@ 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() + { + length = 21; + } + @Override + public void large() + { + length = 63; + } + @Override + public void moveTheLength() + { + Tortoise.move(length); + } + @Override + public void turnTheCorner() + { + Tortoise.turn(-360 / 3); + } + @Override + public void drawASide() + { + moveTheLength(); + turnTheCorner(); } - // - // 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 - // public static void main(String[] args) { new HousesQuizGrader().grade(new HousesQuiz()); From a835123e75e4b4a3e9afe6c57a70a054e3289009 Mon Sep 17 00:00:00 2001 From: WaRP TuX Date: Thu, 20 Jun 2013 14:31:42 -0700 Subject: [PATCH 05/13] you is too mumbojumbo Amittai Mihir --- .../recipes/HiLow.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java index 77e2a75b..ea7e4507 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java @@ -1,20 +1,32 @@ package org.teachingkidsprogramming.recipes; +import org.teachingextensions.logo.utils.Sounds; +import org.teachingextensions.windows.MessageBox; + public class HiLow { public static void main(String[] args) { // Choose a random number between 1 and 100 --#4.1 (fake!) & --#13 // Do the following 8 times --#9 - // Ask the user for a guess --#1 - // If the guess is correct --#4 - // Play a bell --#2 - // Tell the user that they won the game --#3 + int guess = MessageBox.askForNumericalInput("Please guess a number. You have 8 tries."); + int correctNumber = 20; + if (guess == correctNumber) + { + Sounds.playBeep(); + MessageBox.showMessage("YOU WIN :D"); + } // and exit --#10 - // Otherwise, if the guess is too high --#6 - // Tell the end user that it is too high --#5 + else if (guess > correctNumber) + { + MessageBox.showMessage("You is tooooooo mumbo-jumbo!!!"); + } // Otherwise, if the guess is too low --#8 // Tell the end user that it is too low --#7 + else if (guess < correctNumber) + { + MessageBox.showMessage("You is toooooo teeny-weeny!!"); + } // If after 8 times they haven't guessed correctly then --#12 // Tell them they've lost the game --#11 } From 34f8b27e0acf0998461c8eee48fca36d9a8e11db Mon Sep 17 00:00:00 2001 From: WaRP TuX Date: Thu, 20 Jun 2013 14:45:19 -0700 Subject: [PATCH 06/13] Completed Sukkah Mihir Amittai numGame --- .../recipes/HiLow.java | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java index ea7e4507..7f300974 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java @@ -3,31 +3,36 @@ import org.teachingextensions.logo.utils.Sounds; import org.teachingextensions.windows.MessageBox; +import com.spun.util.NumberUtils; + public class HiLow { public static void main(String[] args) { - // Choose a random number between 1 and 100 --#4.1 (fake!) & --#13 - // Do the following 8 times --#9 - int guess = MessageBox.askForNumericalInput("Please guess a number. You have 8 tries."); - int correctNumber = 20; - if (guess == correctNumber) - { - Sounds.playBeep(); - MessageBox.showMessage("YOU WIN :D"); - } - // and exit --#10 - else if (guess > correctNumber) - { - MessageBox.showMessage("You is tooooooo mumbo-jumbo!!!"); - } - // Otherwise, if the guess is too low --#8 - // Tell the end user that it is too low --#7 - else if (guess < correctNumber) + for (int i = 1; i <= 8; i++) { - MessageBox.showMessage("You is toooooo teeny-weeny!!"); + // Choose a random number between 1 and 100 --#4.1 (fake!) & --#13 + // Do the following 8 times --#9 + int guess = MessageBox.askForNumericalInput("Please guess a number. You have 8 tries."); + int correctNumber = NumberUtils.getRandomInt(1, 100); + if (guess == correctNumber) + { + Sounds.playBeep(); + MessageBox.showMessage("YOU WINzip :D"); + // and exit --#10 + System.exit(0); + } + else if (guess > correctNumber) + { + MessageBox.showMessage("You is tooooooo mumbo-jumbo!!!"); + } + else if (guess < correctNumber) + { + MessageBox.showMessage("You is toooooo teeny-weeny!!"); + } + // If after 8 times they haven't guessed correctly then --#12 + // Tell them they've lost the game --#11 } - // If after 8 times they haven't guessed correctly then --#12 - // Tell them they've lost the game --#11 + MessageBox.showMessage("Yu loozez! Sukkah!!!"); } } From 48bdda0fa7381b5db6fa3a595c268bb65d1e2737 Mon Sep 17 00:00:00 2001 From: WaRP TuX Date: Thu, 20 Jun 2013 14:50:07 -0700 Subject: [PATCH 07/13] real final numGame mihir Amittai --- .../src/org/teachingkidsprogramming/recipes/HiLow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java index 7f300974..68a78558 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java @@ -13,7 +13,7 @@ public static void main(String[] args) { // Choose a random number between 1 and 100 --#4.1 (fake!) & --#13 // Do the following 8 times --#9 - int guess = MessageBox.askForNumericalInput("Please guess a number. You have 8 tries."); + int guess = MessageBox.askForNumericalInput("Please guess a number. You have " + (9 - i) + " tries."); int correctNumber = NumberUtils.getRandomInt(1, 100); if (guess == correctNumber) { From b4c20fb22ef067946d69445f02c44a7fb15ba2fe Mon Sep 17 00:00:00 2001 From: WaRP TuX Date: Thu, 20 Jun 2013 15:02:12 -0700 Subject: [PATCH 08/13] displays answer Amittai Mihir --- .../src/org/teachingkidsprogramming/recipes/HiLow.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java index 68a78558..f2750d6e 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java @@ -9,12 +9,12 @@ public class HiLow { public static void main(String[] args) { + int correctNumber = NumberUtils.getRandomInt(1, 100); for (int i = 1; i <= 8; i++) { // Choose a random number between 1 and 100 --#4.1 (fake!) & --#13 // Do the following 8 times --#9 int guess = MessageBox.askForNumericalInput("Please guess a number. You have " + (9 - i) + " tries."); - int correctNumber = NumberUtils.getRandomInt(1, 100); if (guess == correctNumber) { Sounds.playBeep(); @@ -33,6 +33,6 @@ else if (guess < correctNumber) // If after 8 times they haven't guessed correctly then --#12 // Tell them they've lost the game --#11 } - MessageBox.showMessage("Yu loozez! Sukkah!!!"); + MessageBox.showMessage("Yu loozez! Sukkah!!! Da ansah was" + correctNumber); } } From 7b049cb0b090dbf39db028b51ff8c346af9be25f Mon Sep 17 00:00:00 2001 From: WaRP TuX Date: Thu, 20 Jun 2013 15:28:07 -0700 Subject: [PATCH 09/13] ET --- Mihir-Amittai ET/.classpath | 6 ++++++ Mihir-Amittai ET/.project | 17 +++++++++++++++++ .../teachingkidsprogramming/recipes/HiLow.java | 9 +++++---- 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 Mihir-Amittai ET/.classpath create mode 100644 Mihir-Amittai ET/.project diff --git a/Mihir-Amittai ET/.classpath b/Mihir-Amittai ET/.classpath new file mode 100644 index 00000000..fb501163 --- /dev/null +++ b/Mihir-Amittai ET/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Mihir-Amittai ET/.project b/Mihir-Amittai ET/.project new file mode 100644 index 00000000..16e9b98a --- /dev/null +++ b/Mihir-Amittai ET/.project @@ -0,0 +1,17 @@ + + + Mihir-Amittai ET + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java index f2750d6e..4a049a8a 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java @@ -10,15 +10,16 @@ public class HiLow public static void main(String[] args) { int correctNumber = NumberUtils.getRandomInt(1, 100); - for (int i = 1; i <= 8; i++) + int tries = MessageBox.askForNumericalInput("How many tries do you want?"); + for (int i = 1; i <= tries; i++) { // Choose a random number between 1 and 100 --#4.1 (fake!) & --#13 // Do the following 8 times --#9 - int guess = MessageBox.askForNumericalInput("Please guess a number. You have " + (9 - i) + " tries."); + int guess = MessageBox.askForNumericalInput("Please guess a number. You have " + (tries + 1 - i) + " tries."); if (guess == correctNumber) { Sounds.playBeep(); - MessageBox.showMessage("YOU WINzip :D"); + MessageBox.showMessage("YOU WINzip :D\n\nYou took " + i + " tries."); // and exit --#10 System.exit(0); } @@ -33,6 +34,6 @@ else if (guess < correctNumber) // If after 8 times they haven't guessed correctly then --#12 // Tell them they've lost the game --#11 } - MessageBox.showMessage("Yu loozez! Sukkah!!! Da ansah was" + correctNumber); + MessageBox.showMessage("Yu loozez! Sukkah!!! \n\nDa ansah was " + correctNumber); } } From b995dec826962ba3b3d3432d945b82451fd487fe Mon Sep 17 00:00:00 2001 From: WaRP TuX Date: Thu, 20 Jun 2013 15:39:33 -0700 Subject: [PATCH 10/13] ET Mihir Amittai --- .../teachingkidsprogramming/recipes/ET.java | 40 +++++++++++++++++++ .../recipes/HiLow.java | 3 +- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/ET.java diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/ET.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/ET.java new file mode 100644 index 00000000..3166bb5f --- /dev/null +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/ET.java @@ -0,0 +1,40 @@ +package org.teachingkidsprogramming.recipes; + +import org.teachingextensions.logo.utils.Sounds; +import org.teachingextensions.windows.MessageBox; + +import com.spun.util.NumberUtils; + +public class ET +{ + public static void main(String[] args) + { + int correctNumber = NumberUtils.getRandomInt(1, 100); + int tries = MessageBox.askForNumericalInput("How many tries do you want?"); + for (int i = 1; i <= tries; i++) + { + // Choose a random number between 1 and 100 --#4.1 (fake!) & --#13 + // Do the following 8 times --#9 + int guess = MessageBox.askForNumericalInput("Please guess a number between 1 and 100. You have " + + (tries + 1 - i) + " tries."); + if (guess == correctNumber) + { + Sounds.playBeep(); + MessageBox.showMessage("YOU WINzip :D\n\nYou took " + i + " tries."); + // and exit --#10 + System.exit(0); + } + else if (guess > correctNumber) + { + MessageBox.showMessage("You is tooooooo mumbo-jumbo!!!"); + } + else if (guess < correctNumber) + { + MessageBox.showMessage("You is toooooo teeny-weeny!!"); + } + // If after 8 times they haven't guessed correctly then --#12 + // Tell them they've lost the game --#11 + } + MessageBox.showMessage("Yu loozez! Sukkah!!! \n\nDa ansah was " + correctNumber); + } +} diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java index 4a049a8a..90ea376a 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java @@ -15,7 +15,8 @@ public static void main(String[] args) { // Choose a random number between 1 and 100 --#4.1 (fake!) & --#13 // Do the following 8 times --#9 - int guess = MessageBox.askForNumericalInput("Please guess a number. You have " + (tries + 1 - i) + " tries."); + int guess = MessageBox.askForNumericalInput("Please guess a number between 1 and 100. You have " + + (tries + 1 - i) + " tries."); if (guess == correctNumber) { Sounds.playBeep(); From a4e482f41a974cc32de85c2db996a840b56e1e03 Mon Sep 17 00:00:00 2001 From: WaRP TuX Date: Thu, 20 Jun 2013 15:57:27 -0700 Subject: [PATCH 11/13] complete house mihir Amittai --- .../recipes/quizzes/HiLowQuiz.java | 19 ++++++ .../quizzes/graders/HiLowQuizGrader.java | 68 +++++++++++++++++-- 2 files changed, 81 insertions(+), 6 deletions(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/HiLowQuiz.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/HiLowQuiz.java index 00ff0bf6..7ee111f8 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/HiLowQuiz.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/HiLowQuiz.java @@ -1,5 +1,7 @@ package org.teachingkidsprogramming.recipes.quizzes; +import org.teachingextensions.logo.Tortoise; +import org.teachingextensions.windows.MessageBox; import org.teachingkidsprogramming.recipes.quizzes.graders.HiLowQuizGrader; public class HiLowQuiz extends org.teachingkidsprogramming.recipes.quizzes.graders.HiLowQuiz @@ -7,24 +9,41 @@ public class HiLowQuiz extends org.teachingkidsprogramming.recipes.quizzes.grade public void question1() { // if the Y position of the tortoise is 115 + if (Tortoise.getY() == 115) + { + Tortoise.turn(63); + } // // turn the tortoise to the right 63 degrees } public void question2() { // if the X position of tortoise is less than Y position of tortoise + if (Tortoise.getX() < Tortoise.getY()) + { + Tortoise.turn(-54); + } // // turn the tortoise 54 degrees to the left // + else + { + Tortoise.turn(22); + } // otherwise turn the tortoise 22 degrees to the right } public void question3() { // display the message "elcomeway omehay!" + MessageBox.showMessage("elcomeway omehay!"); } public void question4() { // if the Y position of tortoise is greater than 50 + if (50 < Tortoise.getY()) + { + Tortoise.turn(-177); + } // // turn the tortoise 177 degrees to the left } diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/graders/HiLowQuizGrader.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/graders/HiLowQuizGrader.java index 92bd9e31..43566af8 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/graders/HiLowQuizGrader.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/graders/HiLowQuizGrader.java @@ -26,12 +26,68 @@ public void paint(Graphics2D g) } private void drawRewardShape() { - int[] angles = { - 90, -90, -90, 135, -45, 90, 90, -135, 90, 135, -90, 90, 90, 90, -90, -90, -90, -90, -90, 90, 90, 90, -90, - 90, 90, -90, -90, -90}; - int[] lengths = { - 70, 85, 25, 43, 40, 18, 26, 50, 113, 25, 85, 40, 30, 30, 20, 20, 20, 10, 20, 10, 10, 20, 10, 10, 30, 30, - 60, 183}; + Tortoise.setSpeed(10); + Tortoise.hide(); + int[] angles = {90, + -90, + -90, + 135, + -45, + 90, + 90, + -135, + 90, + 135, + -90, + 90, + 90, + 90, + -90, + -90, + -90, + -90, + -90, + 90, + 90, + 90, + -90, + 90, + 90, + -90, + -90, + -90, + 180, + 360}; + int[] lengths = {70, + 85, + 25, + 43, + 40, + 18, + 26, + 50, + 113, + 25, + 85, + 40, + 30, + 30, + 20, + 20, + 20, + 10, + 20, + 10, + 10, + 20, + 10, + 10, + 30, + 30, + 60, + 183, + 183, + 225 - 183}; Tortoise.setX(20); Tortoise.setPenColor(Colors.Greens.LawnGreen); for (int i = 0; i < lengths.length; i++) From d40aa6d370e9913f0b32ec55d4d5794b05abb90a Mon Sep 17 00:00:00 2001 From: Mihir Shah Date: Thu, 20 Jun 2013 22:36:52 -0700 Subject: [PATCH 12/13] Adjusted win message a little-Mihir --- .../src/org/teachingkidsprogramming/recipes/HiLow.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java index 90ea376a..a1f3544f 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java @@ -20,7 +20,8 @@ public static void main(String[] args) if (guess == correctNumber) { Sounds.playBeep(); - MessageBox.showMessage("YOU WINzip :D\n\nYou took " + i + " tries."); + MessageBox.showMessage("Your answer was " + correctNumber + "\n\nYOU WINzip :D\n\nYou took " + i + + " tries."); // and exit --#10 System.exit(0); } From 5db6544c5996520a5c56b95c34439d8b1a29ff56 Mon Sep 17 00:00:00 2001 From: Mihir Shah Date: Thu, 20 Jun 2013 23:12:42 -0700 Subject: [PATCH 13/13] even better-no green stuff-Mihir --- .../src/org/teachingkidsprogramming/recipes/HiLow.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java index a1f3544f..7af943c0 100644 --- a/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java +++ b/TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/HiLow.java @@ -13,8 +13,6 @@ public static void main(String[] args) int tries = MessageBox.askForNumericalInput("How many tries do you want?"); for (int i = 1; i <= tries; i++) { - // Choose a random number between 1 and 100 --#4.1 (fake!) & --#13 - // Do the following 8 times --#9 int guess = MessageBox.askForNumericalInput("Please guess a number between 1 and 100. You have " + (tries + 1 - i) + " tries."); if (guess == correctNumber) @@ -22,7 +20,6 @@ public static void main(String[] args) Sounds.playBeep(); MessageBox.showMessage("Your answer was " + correctNumber + "\n\nYOU WINzip :D\n\nYou took " + i + " tries."); - // and exit --#10 System.exit(0); } else if (guess > correctNumber) @@ -33,8 +30,6 @@ else if (guess < correctNumber) { MessageBox.showMessage("You is toooooo teeny-weeny!!"); } - // If after 8 times they haven't guessed correctly then --#12 - // Tell them they've lost the game --#11 } MessageBox.showMessage("Yu loozez! Sukkah!!! \n\nDa ansah was " + correctNumber); }