|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--acm.graphics.GObject | +--acm.graphics.GTurtle
public class GTurtle extends GObject
The GTurtle class simulates a turtle moving on a canvas. This class is similar to the GPen class, but keeps track of both a position and a direction.
Constructor Summary |
GTurtle() |
GTurtle(double x,
double y) |
Method Summary | |
void | erasePath() |
void | forward() |
void | forward(double distance) |
GRectangle | getBounds() |
double | getDirection() |
double | getSpeed() |
int | getTurtleSize() |
void | hideTurtle() |
boolean | isPenDown() |
boolean | isTurtleVisible() |
void | left(double angle) |
void | main(String[] args) |
void | penDown() |
void | penUp() |
void | right(double angle) |
void | setColor(Color color) |
void | setDirection(double dir) |
void | setLocation(double x,
double y) |
void | setSize(int size) |
void | setSpeed(double speed) |
void | showTurtle() |
Inherited Method Summary | |
Color | getColor() |
GPoint | getLocation()GPoint .
|
GDimension | getSize() |
double | getX() |
double | getX() |
double | getY() |
double | getY() |
boolean | isVisible() |
void | sendBackward() |
void | sendForward() |
void | sendToBack() |
void | sendToFront() |
void | setLocation(GPoint pt) |
void | setVisible(boolean visible) |
Constructor Detail |
public GTurtle()
Usage: | GTurtle turtle = new GTurtle(); |
public GTurtle(double x,
double y)
Usage: | GTurtle turtle = new GTurtle(x, y); | ||||
Parameters: |
|
Method Detail |
public void erasePath()
Usage: | turtle.erasePath(); |
public final void forward()
Usage: | turtle.forward(); |
public void forward(double distance)
Usage: | turtle.forward(distance); | ||
Parameter: |
|
public GRectangle getBounds()
Usage: | bounds = getBounds(); |
Returns: | A GRectangle representing the bounding box |
public double getDirection()
Usage: | double dir = turtle.getDirection(); |
Returns: | The direction in which the turtle is moving |
public double getSpeed()
Usage: | double speed = turtle.getSpeed(); |
Returns: | The current speed of the turtle (0 is slowest, 1 is fastest) |
public int getTurtleSize()
Usage: | int size = turtle.getSize(); |
Returns: | The size of the turtle image in pixels |
public final void hideTurtle()
Usage: | turtle.hideTurtle(); |
public boolean isPenDown()
Usage: | if (turtle.isPenDown()) . . . |
Returns: | true if the pen is down, false otherwise |
public boolean isTurtleVisible()
Usage: | if (turtle.isTurtleVisible()) . . . |
Returns: | true if the turtle is visible, otherwise false |
public final void left(double angle)
Usage: | turtle.left(angle); | ||
Parameter: |
|
public static void main(String[] args)
Usage: | main(args); | ||
Parameter: |
|
public final void penDown()
Usage: | turtle.penDown(); |
public final void penUp()
Usage: | turtle.penUp(); |
public final void right(double angle)
Usage: | turtle.right(angle); | ||
Parameter: |
|
public void setColor(Color color)
Usage: | turtle.setColor(color); | ||
Parameter: |
|
public void setDirection(double dir)
Usage: | turtle.setDirection(dir); | ||
Parameter: |
|
public void setLocation(double x,
double y)
Usage: | turtle.setLocation(x, y); | ||||
Parameters: |
|
public void setSize(int size)
Usage: | turtle.setSize(size); | ||
Parameter: |
|
public void setSpeed(double speed)
Usage: | turtle.setSpeed(speed); | ||
Parameter: |
|
public final void showTurtle()
Usage: | turtle.showTurtle(); |
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |