java.lang.Objectunit4.turtleLib.Turtle
public class Turtle
:לדוגמה, התוכנית הבאה מציירת בעזרת הצב הגרפי ריבוע שצלעותיו בגודל 100 |
import unit4.turtleLib.Turtle; public class TurtleDrawRectangle { public static void main(String[] args) { Turtle t1 = new Turtle(); t1.tailDown(); t1.moveForward(100); t1.turnRight(90); t1.moveForward(100); t1.turnRight(90); t1.moveForward(100); t1.turnRight(90); t1.moveForward(100); t1.tailUp(); t1.moveForward(50); } } |
Constructor Summary | |
---|---|
Turtle()
|
Method Summary | |
---|---|
void |
moveBackward(double x)
|
void |
moveForward(double x)
|
void |
setDelay(int milliseconds)
|
void |
setTailColor(java.lang.String color)
|
void |
setVisible(boolean status)
|
void |
tailDown()
|
void |
tailUp()
|
void |
turnLeft(double d)
|
void |
turnRight(double d)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Turtle()
Method Detail |
---|
public void moveForward(double x)
public void moveBackward(double x)
public void turnLeft(double d)
public void turnRight(double d)
public void tailDown()
public void tailUp()
public void setVisible(boolean status)
status
- ערך 'אמת' יציג את הצב, ערך 'שקר' יסתיר את הצבpublic void setDelay(int milliseconds)
milliseconds
- מספר מילי שניות (גדול מאפס) להמתנה בהזזת הצבpublic void setTailColor(java.lang.String color)
color
- צבעים אפשריים: red,green,blue,black,yellow,white,orange,pink,magenta,gray,lightgray