Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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()
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
}
}