|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectTurtle
public class Turtle
An instance is a turtle in a panel within a JFrame. A turtle is a spot on the panel that you can move from place to place. All instances of Turtle use the same JFrame and panel.
| Field Summary | |
|---|---|
static int |
height
The panel on which the turtle moves is of size (width, height). |
static int |
width
The panel on which the turtle moves is of size (width, height). |
| Constructor Summary | |
|---|---|
Turtle()
Constructor: a black turtle starting at the middle of the panel with angle 0 (looking east). |
|
Turtle(double x,
double y,
double ang)
Constructor: a black turtle starting at (x,y) with angle ang. |
|
| Method Summary | |
|---|---|
void |
addAngle(double ang)
Add ang degrees to the angle. |
void |
clear()
Clear the screen (make it all white). |
void |
drawCircle(double d)
Draw a circle with center at current pen position of diameter d. |
void |
drawRectangle(double w,
double h)
Draw a rectangle with center at current pen position of width w, height h. |
void |
fillCircle(double d)
Fill a circle with center at current pen position of diameter d. |
void |
fillRectangle(double w,
double h)
Fill a rectangle with center at current pen position of width w, height h. |
double |
getAngle()
= angle of the turtle (in degrees). |
Color |
getColor()
= the current color. |
int |
getHeight()
= height of the panel. |
int |
getWidth()
= width of panel. |
double |
getX()
= x-coordinate of the turtle. |
double |
getY()
= y-coordinate of the panel. |
void |
liftPen()
Lift pen. |
void |
move(double d)
Move the turtle d units in its current direction. |
void |
moveTo(double x,
double y,
double ang)
Move the turtle to (x,y), without drawing, and face it at angle ang. |
void |
pause(int msec)
Pause the program for msec milliseconds. |
void |
putPenDown()
Put pen down. |
void |
setAngle(double ang)
Set the angle to ang degrees. |
void |
setColor(Color c)
Set the color of the turtle to c. |
void |
setPanelSize()
Set panel size as big as possible in the current window. |
static Color |
tColor(int c)
= the Color value for c. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static int width
public static int height
| Constructor Detail |
|---|
public Turtle()
public Turtle(double x,
double y,
double ang)
| Method Detail |
|---|
public static Color tColor(int c)
public void setPanelSize()
public double getX()
public double getY()
public double getAngle()
public int getWidth()
public int getHeight()
public void setAngle(double ang)
public void addAngle(double ang)
public void liftPen()
public void putPenDown()
public void setColor(Color c)
public Color getColor()
public void moveTo(double x,
double y,
double ang)
public void drawCircle(double d)
public void fillCircle(double d)
public void drawRectangle(double w,
double h)
public void fillRectangle(double w,
double h)
public void move(double d)
public void clear()
public void pause(int msec)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||