Right click the TurtleWorld class icon and choose Open editor to view the code. Comment on the first line of the constructor TurtleWorld().
Change the background colour of TurtleWorld.
Add one of each turtle and run them: square, spiral, flower and circle. Use the Act button to draw slowly.
Look at the code for squareTurtle. Explain the meaning of the words: "public class SquareTurtle extends Turtle".
What is the function of "public SquareTurtle()"?
What is the function of "public void act()"?
Explain what "public void GoAndTurn" does. Is this essential to the way the program works?
Where are the move() and turn() functions to be found?
Explain the meaning of: "public class Turtle extends Actor".
Explain the meaning of the three words: "private boolean pendown;".
Explain the meaning of the three words: "private double direction;".
Explain the meaning of this: "private final static double MAX_ANGLE = 360;".
What action is performed if the angle in a program is greater than MAX_ANGLE?
What does the % operator do in Java? If the angle is 370, what is 370 % MAX_ANGLE ?
What is "public Turtle()"? How can you tell? What does this function does with the turtle image?
Explain the meaning of the words in: "public void turn (double degrees)"
What does 'setRotation((int) direction)' do?
Extension:
The function setRotation() is not defined in Turtle. How does the program know about it? Where can setRotation() be found? (Use the API guide to help answer this.)
In the public moveTo function what is the purpose of this block of code: if (pendown) { } ?
In the public moveTo function what is the purpose of x=newX and y=newY?
Write an account of how the turtle moves from one place to another.
What is the relationship between SpiralTurtle, CircleTurtle and SquareTurtle to Turtle?
What does the function turn() do?
In 'public void turn (double degrees)', what name is given to 'double degrees'?
What does the function 'addedToWorld(World world)' do?
What does the function move(double distance) do?
Describe what the function moveTo() does.
Which pre-defined class provides the drawing routines for the turtle graphics?
Give three examples of drawing functions included in the pre-defined class.
What is the difference between the two versions of 'setLocation'?
In public setLocation what is the function of "this" and of "super"?
Add a new turtle that draws a hexagon.
Add a new turtle that extends turtleSquare to draw a pattern (the pattern is formed by drawing a square and then rotating the turtle before drawing another square and so on. This can be done by creating a new subclass inside turtleSquare.)
Add an new turtle that draws a regular three sided spiral (this will be very similar to SpiralTurtle).
Add a new turtle that draws a three sided spiral with an angle of 59 degrees
Add a new turtle that draws a five pointed star and stars with 7 and 9 points. Note that the angle of turn is oblique. How do you calculate the angle of turn? Devise a formula for finding the angle of turn for an n pointed star.
Change the angle of turn to draw a 9 point star. What is the angle of turn? Multiply the angle of turn by the number of points: what do you notice about this product?
What other stars can you draw?
Add a new turtle that moves and turns in random amounts.