|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectWatorWorld.Actor
public class Actor
An Actor
is an entity with a color and direction that can act.
The API of this class is testable on the AP CS A and AB exams.
Constructor Summary | |
---|---|
Actor()
Constructs a blue actor that is facing north. |
Method Summary | |
---|---|
void |
act()
Reverses the direction of this actor. |
char |
getChar()
Get a simple one char representation of this sea creature. |
Color |
getColor()
Gets the color of this actor. |
int |
getDirection()
Gets the current direction of this actor. |
Grid<Actor> |
getGrid()
Gets the grid in which this actor is located. |
Location |
getLocation()
Gets the location of this actor. |
boolean |
isEdible()
Check to see if this sea creature can be eaten by other sea creatures |
void |
moveTo(Location newLocation)
Moves this actor to a new location. |
void |
putSelfInGrid(Grid<Actor> gr,
Location loc)
Puts this actor into a grid. |
void |
removeSelfFromGrid()
Removes this actor from its grid. |
void |
setColor(Color newColor)
Sets the color of this actor. |
void |
setDirection(int newDirection)
Sets the current direction of this actor. |
String |
toString()
Creates a string that describes this actor. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Actor()
Method Detail |
---|
public Color getColor()
public void setColor(Color newColor)
newColor
- the new colorpublic int getDirection()
public void setDirection(int newDirection)
newDirection
- the new direction. The direction of this actor is set
to the angle between 0 and 359 degrees that is equivalent to
newDirection
.public Grid<Actor> getGrid()
null
if this actor is
not contained in a gridpublic Location getLocation()
null
if this actor is
not contained in a gridpublic void putSelfInGrid(Grid<Actor> gr, Location loc)
loc
is valid in gr
gr
- the grid into which this actor should be placedloc
- the location into which the actor should be placedpublic void removeSelfFromGrid()
public void moveTo(Location newLocation)
newLocation
is valid in the grid of this actor
newLocation
- the new locationpublic void act()
Actor
to define types of actors with different behavior
public String toString()
toString
in class Object
public char getChar()
public boolean isEdible()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |