|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object intro.ex1.IntroTurtle
public class IntroTurtle
Once instantiated, an object of this class opens a window with black background and a white turtle.
The turtle has an imaginary pen. When the pen is down and the turtle moves, it leaves a trace on the window.The class uses code written by Guy Haas for a java course in BFOIT.
Constructor Summary | |
---|---|
IntroTurtle()
Instantiates a new IntroTurtle. |
Method Summary | |
---|---|
void |
back(int steps)
Moves the turtle backward by the given amount of steps. |
void |
forward(int steps)
Moves the turtle forward by the given amount of steps. |
void |
hideTurtle()
Makes the turtle invisible. |
void |
left(int degrees)
Rotates the turtle to the left by the given number of degrees. |
void |
penDown()
Puts the pen down. |
void |
penUp()
Lifts the pen up. |
void |
right(int degrees)
Rotates the turtle to the right by the given number of degrees. |
void |
setPenColor(int colorNumber)
Sets the color of the turtle's pen according to the supplied number. |
void |
setPenSize(int width)
Sets the turtle's pen size to the supplied width. |
void |
showTurtle()
Makes the turtle visible. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IntroTurtle()
Method Detail |
---|
public void back(int steps)
steps
- The amount of steps to move the turtle by.public void forward(int steps)
steps
- The amount of steps to move the turtle by.public void right(int degrees)
degrees
- the amount of degrees by which the turtle should be rotated.public void left(int degrees)
degrees
- the amount of degrees by which the turtle should be rotated.public void penUp()
public void penDown()
public void setPenColor(int colorNumber)
colorNumber
- Determines the pen color according to this table:
Number | Color | Number | Color |
0 | black | 8 | brown |
1 | blue | 9 | tan |
2 | green | 10 | forest |
3 | cyan | 11 | aqua |
4 | red | 12 | salmon |
5 | magenta | 13 | violet |
6 | yellow | 14 | orange |
7 | white | 15 | grey |
public void setPenSize(int width)
width
- 1 or less gives a single pixel line, each increase enlarges the width by about 2 pixels.public void hideTurtle()
public void showTurtle()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |