Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions Game1/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions Game1/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Game1</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
1 change: 1 addition & 0 deletions TeachingKidsProgramming/.class.virtual_proctor.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Grace Hopper's Class
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static void main(String[] args)
{
// Show the tortoise --#1
Tortoise.show();
for (int i = 0; i < 75; i++)
for (int i = 0; i < 1000; i++)
{
// Make the tortoise go as fast as possible --#4
Tortoise.setSpeed(10);
Expand All @@ -27,9 +27,9 @@ public static void main(String[] args)
// 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);
Tortoise.move(i * 1);
// Turn the tortoise 1/3 of 360 degrees to the right --#2
Tortoise.turn(125);
Tortoise.turn(79);
}
catch (RuntimeException re)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,54 @@ public static void main(String[] args) throws Exception
Tortoise.setPenColor(PenColors.Yellows.Gold);
//
// Set the speed to the fastest --#8
Tortoise.setSpeed(10);
// Update the length to 100.0 --#1.1
double length = 50.0;
double length = 100.0;
// MakeASquare with the current length(recipe below) --#11.4
//
makeASquare(length);
//We fixed a recursion problem
for (int i = 0; i < 4; i++)
{
length = length / 1.7;
makeASquare(length);
}
}
private static void makeASquare(double length)
{
// Create the makeASquare recipe --#11.1
// If the current length is greater than 10 --#10.2
// Run the recipe moveToTheSquareStart with the current length --#4.3
//
// Create the moveToTheSquareStart recipe --#4.1
// Set the pen up for the tortoise --#1.2
// Move the tortoise the current length divided by two --#1.3
// Turn the tortoise 90 degrees to the left --#2.1
// Move the tortoise the current length divided by two --#2.2
// Turn the tortoise 180 degrees to the right --#3.1
// Set the pen down for the tortoise --#3.2
// End of moveToTheSquareStart recipe --#4.2
if (length > 10)
{
// Run the recipe moveToTheSquareStart with the current length --#4.3
moveToTheSquareStart(length);
}
//
// Do the following 4 times --#7.1
// Move the Tortoise the current length --#6.2
// MakeASquare with the current length divided by 1.7 (recipe below)--#11.3
// If the current process count is less than 3 (HINT: use 'i') --#9
// Turn the tortoise 90 degrees to the right --#6.1
// Repeat --#7.2
for (int i = 0; i < 4; i++)
{
// Move the Tortoise the current length --#6.2
Tortoise.move(length);
// MakeASquare with the current length divided by 1.7 (recipe below)--#11.3
// If the current process count is less than 3 (HINT: use 'i') --#9
if (i < 3)
{
// Turn the tortoise 90 degrees to the right --#6.1
Tortoise.turn(90);
}
// Repeat --#7.2
}
//
// MoveBackToCenter with the current length (recipe below)--#5.3
moveBackToCenter(length);
//
// Set the current length to the current length times two --#10.1
length = length * 2;
//
// End of makeASquare recipe --#11.2
}
private static void moveBackToCenter(double length)
{
// Create the moveBackToCenter recipe --#5.1
Tortoise.setPenUp();
Tortoise.turn(90);
Expand All @@ -48,9 +71,22 @@ public static void main(String[] args) throws Exception
//
//
// End of moveBackToCenter recipe--#5.2
//
// Set the current length to the current length times two --#10.1
//
// End of makeASquare recipe --#11.2
}
private static void moveToTheSquareStart(double length)
{
// Create the moveToTheSquareStart recipe --#4.1
// Set the pen up for the tortoise --#1.2
Tortoise.setPenUp();
// Move the tortoise the current length divided by two --#1.3
Tortoise.move(length / 2);
// Turn the tortoise 90 degrees to the left --#2.1
Tortoise.turn(-90);
// Move the tortoise the current length divided by two --#2.2
Tortoise.move(length / 2);
// Turn the tortoise 180 degrees to the right --#3.1
Tortoise.turn(180);
// Set the pen down for the tortoise --#3.2
Tortoise.setPenDown();
// End of moveToTheSquareStart recipe --#4.2
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,91 @@
import java.util.HashMap;

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

public class TurtleTree
{
@SuppressWarnings("unused")
public static void main(String[] args)
{
Tortoise.show();
// Make the tortoise go as fast as possible --#10
Tortoise.setSpeed(10);
// Turn the background black --#21
Tortoise.getBackgroundWindow().setBackground(Grays.Black);
// The current branch length = 60 --#1.2
int branchLength = 60;
// drawBranch(recipe below) --#2.1
//
drawBranch(branchLength);
}
private static void drawBranch(int branchLength)
{
// ------------- Recipe for drawBranch --#2.2
// If the current branch length is greater than zero, do the rest of this recipe --#5
// adjustColor (recipe below)--#15.1
if (branchLength > 0)
{
// adjustColor (recipe below)--#15.1
adjustColor(branchLength);
//
// Move the tortoise the length of the current branch --#1.1
Tortoise.move(branchLength);
// drawLowerBranches (recipe below) --#6.1
adjustColor(branchLength);
//
drawLowerBranches(branchLength);
branchLength = branchLength + 10;
adjustColor(branchLength);
//
}
// ------------- End of drawBranch recipe --#2.3
}
private static void drawLowerBranches(int branchLength)
{
// ------------- Recipe for drawLowerBranches --#6.2
// Turn the Tortoise 30 degrees to the right --#3
Tortoise.turn(30);
// drawShorterBranch (recipe below) --#8.1
//
drawShorterBranch(branchLength);
//
// Turn the Tortoise 60 degrees to the left --#7
Tortoise.turn(-60);
// drawShorterBranch --#9
drawShorterBranch(branchLength);
// Turn the Tortoise 30 degrees to the right --#12
Tortoise.turn(30);
// adjustColor --#16
// Move the tortoise backward the length of the current branch --#11
Tortoise.move(-branchLength);
// ------------- End of drawLowerBranches recipe --#6.3
}
private static void adjustColor(int branchLength)
{
// ------------- Recipe for adjustColor --#15.2
HashMap<Integer, Color> colors = new HashMap<Integer, Color>();
// A 10 pixel long branch is lime --#20
colors.put(10, Greens.Lime);
// A 20 pixel long branch is forest green --#19
colors.put(20, Greens.ForestGreen);
// A 30 pixel long branch is dark green --#18
colors.put(30, Greens.DarkGreen);
// A 40 pixel long branch is olive --#17
colors.put(40, Greens.Olive);
// A 50 pixel long branch is sienna --#14
colors.put(50, Browns.Sienna);
// A 60 pixel long branch is saddle brown (TIP: Put the values into the 'colors' HashMap)--#13
colors.put(60, Browns.SaddleBrown);
// Get the value of the branch length from the 'colors' HashMap and use that to set the pen color --#21
Tortoise.setPenColor(colors.get(branchLength));
// ------------- End of adjustColor --#15.3
//
// Move the tortoise the length of the current branch --#1.1
// drawLowerBranches (recipe below) --#6.1
//
// ------------- Recipe for drawLowerBranches --#6.2
// Turn the Tortoise 30 degrees to the right --#3
// drawShorterBranch (recipe below) --#8.1
//
}
private static void drawShorterBranch(int branchLength)
{
// ------------- Recipe for drawShorterBranch --#8.2
// drawBranch (10 pixels shorter) --#4
drawBranch(branchLength - 10);
// ------------- End of drawShorterBranch recipe --#8.3
//
// Turn the Tortoise 60 degrees to the left --#7
// drawShorterBranch --#9
// Turn the Tortoise 30 degrees to the right --#12
// adjustColor --#16
// Move the tortoise backward the length of the current branch --#11
// ------------- End of drawLowerBranches recipe --#6.3
//
// ------------- End of drawBranch recipe --#2.3
}
}
Loading