Class Turtle

java.lang.Object
  extended by Turtle

public class Turtle
extends java.lang.Object

A class representing a Papert-style Turtle that can be moved about a canvas. This class acts as an initializer and wrapper for the JTF Turtle, so that it can be controlled through the BlueJ interface Note that this class uses a singleton canvas (run as an applet)

Version:
Aug 2013
Author:
Joel

Constructor Summary
Turtle()
          Constructor for objects of class Turtle
 
Method Summary
 void forward()
          Moves the turtle forward by one "step" (the size of the turtle; 30 pixels).
 void forward(int distance)
          Moves the turtle forward the specified distance (in pixels)
 double getDirection()
          Gets the turtle's current facing (in degrees counterclockwise from the x axis)
 java.awt.Color getPenColor()
          Returns the color of the turtle's pen.
 java.lang.String getPenColorName()
          Returns the name of the color of the turtle's pen.
 double getSpeed()
          Gets the turtle's current speed.
 boolean isPenDown()
          Gets whether the turtle's pen is down or not.
 void left(int angle)
          Turns the turtle to the left the specified number of degrees
 void penDown()
          Puts the turtle's pen down.
 void penUp()
          Lifts the turtle's pen up.
 void printText(java.lang.String message)
          Prints the given message on the screen.
 void right(int angle)
          Turns the turtle to the right the specified number of degrees
 void setPenColor(java.awt.Color color)
          Sets the color of the turtle's pen.
 void setPenColorByName(java.lang.String color)
          Sets the color of the turtle's pen, using the name of the color.
 void setSpeed(double speed)
          Sets the turtle's speed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Turtle

public Turtle()
Constructor for objects of class Turtle

Method Detail

forward

public void forward()
Moves the turtle forward by one "step" (the size of the turtle; 30 pixels).


forward

public void forward(int distance)
Moves the turtle forward the specified distance (in pixels)


getDirection

public double getDirection()
Gets the turtle's current facing (in degrees counterclockwise from the x axis)


getPenColor

public java.awt.Color getPenColor()
Returns the color of the turtle's pen. Note that this will look like jibberish in BlueJ.


getPenColorName

public java.lang.String getPenColorName()
Returns the name of the color of the turtle's pen.


getSpeed

public double getSpeed()
Gets the turtle's current speed. 0.5 is default, 1 is fastest, 0 is slowest.


isPenDown

public boolean isPenDown()
Gets whether the turtle's pen is down or not.


left

public void left(int angle)
Turns the turtle to the left the specified number of degrees


penDown

public void penDown()
Puts the turtle's pen down.


penUp

public void penUp()
Lifts the turtle's pen up.


printText

public void printText(java.lang.String message)
Prints the given message on the screen. Note that this will not move the turtle.


right

public void right(int angle)
Turns the turtle to the right the specified number of degrees


setPenColor

public void setPenColor(java.awt.Color color)
Sets the color of the turtle's pen. Note that if called through BlueJ, you will need to specify the full path to the color (i.e., java.awt.Color.RED or java.awt.Color.BLUE).


setPenColorByName

public void setPenColorByName(java.lang.String color)
Sets the color of the turtle's pen, using the name of the color. Can either be: "red", "green", "blue", "cyan", "magenta", "yellow", "pink", "gray", "black", "white"


setSpeed

public void setSpeed(double speed)
Sets the turtle's speed. 0.5 is default, 1 is fastest, 0 is slowest.