|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSimpleTurtle
public class SimpleTurtle
Class that represents a Logo-style turtle. The turtle starts off facing north. A turtle can have a name, has a starting x and y position, has a heading, has a width, has a height, has a visible flag, has a body color, can have a shell color, and has a pen. You can display this turtle in either a picture or in a class that implements ModelDisplay. Copyright Georgia Institute of Technology 2004
Constructor Summary | |
---|---|
SimpleTurtle(int x,
int y)
Constructor that takes the x and y position for the turtle |
|
SimpleTurtle(int x,
int y,
ModelDisplay display)
Constructor that takes the x and y position and the model displayer |
|
SimpleTurtle(int x,
int y,
Picture picture)
Constructor that takes the x and y position and the picture to draw on |
|
SimpleTurtle(ModelDisplay display)
Constructor that takes a model display and adds a turtle in the middle of it |
|
SimpleTurtle(Picture picture)
Constructor that takes the picture to draw on and will appear in the middle |
Method Summary | |
---|---|
void |
drawInfoString(java.awt.Graphics g)
Method to draw the information string |
void |
drop(Picture dropPicture)
Method to draw a passed picture at the current turtle location and rotation |
void |
forward(int pixels)
Method to move the turtle forward the given number of pixels |
java.awt.Color |
getBodyColor()
Method to get the body color |
int |
getHeading()
Method to get the current heading |
java.awt.Color |
getInfoColor()
Method to get the information color |
java.lang.String |
getName()
Method to get the name of the turtle |
Pen |
getPen()
Method to get the pen from the turtle |
java.awt.Color |
getPenColor()
Method to get the pen color |
int |
getPenWidth()
Method to get the pen width |
java.awt.Color |
getShellColor()
Method to get the shell color |
boolean |
getShowInfo()
Method to get value of show info |
int |
getXPos()
Method to get the current x position |
int |
getYPos()
Method to get the current y position |
boolean |
isPenDown()
Method to check if the pen is down |
boolean |
isVisible()
Method to get the value of the visible flag |
void |
moveTo(int x,
int y)
Method to move to turtle to the given x and y location |
void |
paintComponent(java.awt.Graphics g)
Method to paint the turtle |
void |
setBodyColor(java.awt.Color color)
Method to set the body color |
void |
setHeading(int heading)
Method to set the heading |
void |
setInfoColor(java.awt.Color color)
Method to set the information color |
void |
setName(java.lang.String name)
Method to set the name of the turtle |
void |
setPen(Pen pen)
Method to set the pen for this turtle |
void |
setPenColor(java.awt.Color color)
Method to set the pen color |
void |
setPenDown(boolean value)
Method to set the pen down boolean variable |
void |
setPenWidth(int width)
Method to set the pen width |
void |
setShellColor(java.awt.Color color)
Method to set the shell color |
void |
setShowInfo(boolean value)
Method to show the turtle information string |
void |
setVisible(boolean value)
Method to set the visible flag |
java.lang.String |
toString()
Method to return a string with informaiton about this turtle |
void |
turn(int degrees)
Method to turn the turtle the passed degrees use negative to turn left and pos to turn right |
void |
turnLeft()
Method to turn left |
void |
turnRight()
Method to turn right |
void |
updateDisplay()
Method to update the display of this turtle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SimpleTurtle(int x, int y)
x
- the x posy
- the y pospublic SimpleTurtle(int x, int y, ModelDisplay display)
x
- the x posy
- the y posdisplay
- the model displaypublic SimpleTurtle(ModelDisplay display)
display
- the model displaypublic SimpleTurtle(int x, int y, Picture picture)
x
- the x posy
- the y pospicture
- the picture to draw onpublic SimpleTurtle(Picture picture)
picture
- the picture to draw onMethod Detail |
---|
public boolean getShowInfo()
public void setShowInfo(boolean value)
value
- the value to set showInfo topublic java.awt.Color getShellColor()
public void setShellColor(java.awt.Color color)
color
- the color to usepublic java.awt.Color getBodyColor()
public void setBodyColor(java.awt.Color color)
color
- the color to usepublic java.awt.Color getInfoColor()
public void setInfoColor(java.awt.Color color)
color
- the new color to usepublic int getXPos()
public int getYPos()
public boolean isPenDown()
public void setPenDown(boolean value)
value
- the value to set it topublic java.awt.Color getPenColor()
public void setPenColor(java.awt.Color color)
color
- the color for the pen inkpublic void setPenWidth(int width)
width
- the width to use in pixelspublic int getPenWidth()
public Pen getPen()
public void setPen(Pen pen)
pen
- the pen to usepublic int getHeading()
public void setHeading(int heading)
heading
- the new heading to usepublic java.lang.String getName()
public void setName(java.lang.String name)
name
- the new name to usepublic boolean isVisible()
public void setVisible(boolean value)
value
- the value to set it topublic void updateDisplay()
public void forward(int pixels)
pixels
- the number of pixels to walk forward in the heading directionpublic void moveTo(int x, int y)
public void turnLeft()
public void turnRight()
public void turn(int degrees)
degrees
- the amount to turn in degreespublic void drop(Picture dropPicture)
dropPicture
- the picture to droppublic void paintComponent(java.awt.Graphics g)
public void drawInfoString(java.awt.Graphics g)
g
- the graphics contextpublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |