Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,65 @@
import org.teachingextensions.logo.Tortoise;
import org.teachingextensions.logo.utils.ColorUtils.ColorWheel;
import org.teachingextensions.logo.utils.ColorUtils.PenColors;
import org.teachingextensions.logo.utils.ColorUtils.PenColors.Grays;

public class DoubleLoop
{
public static void main(String[] args)
{
Tortoise.show();
// Set the tortoise x position to 225 --#1.1
Tortoise.setX(225);
// Set the tortoise y position to 150 --#1.2
Tortoise.setY(150);
// UPDATE the tortoise speed to 10 --#8.2
Tortoise.setSpeed(5);
Tortoise.setSpeed(10);
//
ColorWheel.addColor(PenColors.Reds.Crimson);
ColorWheel.addColor(PenColors.Reds.DarkRed);
ColorWheel.addColor(PenColors.Reds.FireBrick);
// Do the following 6 times --#3.1
// Change the pen color of the line the tortoise draws to the next color on the Color Wheel --#5
// Move the tortoise 4 times the current line number you are drawing --#4
// Turn the tortoise 1/6 of 360 degrees to the left --#2
//
// Do the following 15 times --(HINT: The new line number is j) --#7.1
// Set the pen width of the line the tortoise draws to 17 --#9
// Move the tortoise 8 times the current line number you are drawing --#8.1
// Turn the tortoise 1/5 of 360 degrees to the right --#6
// Repeat --#7.2
//
// Hide the Tortoise --#10
Tortoise.getBackgroundWindow().setBackground(PenColors.Yellows.PeachPuff);
// Repeat --#3.2
// Do the following 6 times --#3.1
for (int i = 0; i < 6; i++)
{
// Change the pen color of the line the tortoise draws to the next color on the Color Wheel --#5
Tortoise.setPenColor(ColorWheel.getNextColor());
// Move the tortoise 4 times the current line number you are drawing --#4
Tortoise.move(i * 4);
// Turn the tortoise 1/6 of 360 degrees to the left --#2
Tortoise.turn(360 / -6);
//
// Do the following 15 times --(HINT: The new line number is j) --#7.1
for (int j = 0; j < 15; j++)
{
// Set the pen width of the line the tortoise draws to 17 --#9
Tortoise.setPenWidth(17);
// Move the tortoise 8 times the current line number you are drawing --#8.1
Tortoise.move(j * 8);
// Turn the tortoise 1/5 of 360 degrees to the right --#6
Tortoise.turn(360 / 5);
}
// Repeat --#7.2
//
// Hide the Tortoise --#10
Tortoise.hide();
Tortoise.getBackgroundWindow().setBackground(PenColors.Yellows.PeachPuff);
// Repeat --#3.2
}
// Set the tortoise x position to 300 --#15.1
Tortoise.setX(300);
// Set the tortoise y position to 200 --#15.2
Tortoise.setY(200);
// Do the following 5 times --#12.1
// Change the pen color of the line the tortoise draws to black --#14
// Move the Tortoise 25 pixels --#11
// Turn the tortoise 1/5 of 360 degrees to the right --#13
// Repeat --#12.2
//
for (int i = 0; i < 5; i++)
{
// Change the pen color of the line the tortoise draws to black --#14
Tortoise.setPenColor(Grays.Black);
// Move the Tortoise 25 pixels --#11
Tortoise.move(25);
// Turn the tortoise 1/5 of 360 degrees to the right --#13
Tortoise.turn(360 / 5);
// Repeat --#12.2
//
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
package org.teachingkidsprogramming.section01forloops;

import org.teachingextensions.logo.Tortoise;
import org.teachingextensions.logo.utils.ColorUtils.PenColors;

public class SimpleSquare
{
public static void main(String[] args) throws Exception
{
// Show the tortoise --#1
// Make the tortoise move as fast as possible --#6
// Do the following 4 times --#5.1
// Change the pen color of the line the tortoise draws to blue --#4
// Move the tortoise 50 pixels --#2
// Turn the tortoise to the right (90 degrees) --#3
Tortoise.show();
for (int i = 0; i < 4; i++)
{
// Make the tortoise move as fast as possible --#6
// Do the following 4 times --#5.1
// Change the pen color of the line the tortoise draws to blue --#4
Tortoise.setPenColor(PenColors.Blues.Blue);
// Move the tortoise 50 pixels --#2
Tortoise.move(50);
// Turn the tortoise to the right (90 degrees) --#3
Tortoise.turn(90);
}
// Repeat --#5.2
//
// (Optional): Sign your work using the Virtual Proctor
// See your work at http://virtualproctor.tkpjava.org
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.teachingkidsprogramming.section01forloops;

import org.teachingextensions.logo.Tortoise;
import org.teachingextensions.logo.utils.ColorUtils.PenColors.Yellows;
import org.teachingkidsprogramming.recipes.quizzes.graders.SimpleSquareQuizGrader;
import org.teachingkidsprogramming.recipes.quizzes.graders.SquareQuiz;

Expand All @@ -8,18 +10,22 @@ public class SimpleSquareQuiz implements SquareQuiz
public void question1()
{
// Move the tortoise 110 pixels
Tortoise.move(110);
}
public void question2()
{
// Turn the tortoise 1/5 of 360 degrees to the right
Tortoise.turn(360 / 5);
}
public void question3()
{
// Change the pen color the tortoise draws to yellow
Tortoise.setPenColor(Yellows.Yellow);
}
public void question4()
{
// Change the width of the line the tortoise draws to 5 pixels
Tortoise.setPenWidth(5);
}
public static void main(String[] args)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
package org.teachingkidsprogramming.section01forloops;

import org.teachingextensions.logo.Tortoise;
import org.teachingextensions.logo.utils.ColorUtils.ColorWheel;
import org.teachingextensions.logo.utils.ColorUtils.PenColors.Purples;
import org.teachingextensions.logo.utils.EventUtils.MessageBox;

public class Spiral
{
public static void main(String[] args)
{
// Show the tortoise --#1
// Make the tortoise go as fast as possible --#4
// Add Blue Violet to the Color Wheel --#7
// Add Violet to the Color Wheel --#8
// Add Purple to the Color Wheel --#9
// Do the following 75 times --#3.1
try
Tortoise.show();
for (int i = 0; i < 75; i++)
{
// Change the pen color of the line the tortoise draws the next color on the Color Wheel --#6
// Move the tortoise 5 times the current line number you are drawing --#5
// Turn the tortoise 1/3 of 360 degrees to the right --#2
// Make the tortoise go as fast as possible --#4
Tortoise.setSpeed(10);
// Add Blue Violet to the Color Wheel --#7
ColorWheel.addColor(Purples.BlueViolet);
// Add Violet to the Color Wheel --#8
ColorWheel.addColor(Purples.Violet);
// Add Purple to the Color Wheel --#9
ColorWheel.addColor(Purples.Purple);
// Do the following 75 times --#3.1
try
{
// Change the pen color of the line the tortoise draws the next color on the Color Wheel --#6
Tortoise.setPenColor(ColorWheel.getNextColor());
// Move the tortoise 5 times the current line number you are drawing --#5
Tortoise.move(i * 5);
// Turn the tortoise 1/3 of 360 degrees to the right --#2
Tortoise.turn(125);
}
catch (RuntimeException re)
{
MessageBox.showMessage("Hold up: " + re);
}
// Repeat --#3.2
}
catch (RuntimeException re)
{
MessageBox.showMessage("Hold up: " + re);
}
// Repeat --#3.2
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,49 @@
package org.teachingkidsprogramming.section02methods;

import org.teachingextensions.logo.Tortoise;
import org.teachingextensions.logo.utils.ColorUtils.PenColors.Grays;

public class Houses
{
public static void main(String[] args)
{
Tortoise.show();
// Make the tortoise move as fast as possible --#11
Tortoise.setSpeed(10);
// Have the tortoise start at 200 pixels in on the X axis --#14
Tortoise.setX(200);
// The current height is 40 --#1.2
int currentHeight = 40;
// drawHouse (recipe below) --#9.1
drawHouse(currentHeight);
// drawHouse with height 120 (recipe below) --#10
drawHouse(120);
// drawHouse with height 90 (recipe below) --#12
drawHouse(90);
// drawHouse with height 20 (recipe below) --#13
drawHouse(20);
}
private static void drawHouse(int currentHeight)
{
// ------------- Recipe for drawHouse --#9.2
// Change the pen color of the line the tortoise draws to lightGray --#15
Tortoise.setPenColor(Grays.LightGray);
// Move the tortoise the height of a house --#1.1
Tortoise.move(currentHeight);
// Turn the tortoise 90 degrees to the right --#2
Tortoise.turn(90);
// Move the tortoise 30 pixels --#3
Tortoise.move(30);
// Turn the tortoise 90 degrees to the right --#4
Tortoise.turn(90);
// Move the tortoise the height of a house --#5
Tortoise.move(currentHeight);
// Turn the tortoise 90 degrees to the left --#6
Tortoise.turn(-90);
// Move the tortoise 20 pixels --#7
Tortoise.move(20);
// Turn the tortoise 90 degrees to the left --#8
Tortoise.turn(-90);
// ------------- End of drawHouse recipe --#9.3
// drawHouse with height 120 (recipe below) --#10
// drawHouse with height 90 (recipe below) --#12
// drawHouse with height 20 (recipe below) --#13
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.teachingkidsprogramming.section02methods;

import org.teachingextensions.logo.Tortoise;
import org.teachingkidsprogramming.recipes.quizzes.graders.HousesQuizAdapter;
import org.teachingkidsprogramming.recipes.quizzes.graders.HousesQuizGrader;

Expand All @@ -10,39 +11,60 @@ public void questions1Thru6()
// Question 1
// small (recipe below)
// ------------- Recipe for small
length = 7;
small();
// ------------- End of small recipe
//
// Question2
// medium (recipe below)
// ------------- Recipe for medium
// set the current length to 21
medium();
// ------------- End of medium recipe
//
// Question3
// large (recipe below)
// ------------- Recipe for large
// set the current length to 63
// ------------- End of large recipe
//
// Question4
// moveTheLength (recipe below)
// ------------- Recipe for moveTheLength
// move the Tortoise the current length
// ------------- End of moveTheLength recipe
//
// Question5
// turnTheCorner (recipe below)
// ------------- Recipe for turnTheCorner
// turn the Tortoise 1/3 of 360 degrees to the left
large();
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()
{
Tortoise.turn(-120);
}
private void moveTheLength()
{
Tortoise.move(length);
}
private void large()
{
length = 63;
}
private void medium()
{
length = 21;
}
private void medium()
{
medium();
}
private void small()
{
length = 7;
}
public static void main(String[] args)
{
new HousesQuizGrader().grade(new HousesQuiz());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.teachingkidsprogramming.section02methods;

import org.teachingextensions.logo.Tortoise;
import org.teachingextensions.logo.utils.ColorUtils.PenColors;

@SuppressWarnings("unused")
public class TriangleShell
Expand All @@ -8,20 +10,38 @@ 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
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
//
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)
{
// ------------- 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
// 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
//
// Turn the tortoise 1/60th of 360 degrees to the right --#10
// Repeat --#7.2
}
}
Loading