| Constructor and Description |
|---|
Actor()
Constructs a blue actor that is facing north.
|
| Modifier and Type | Method and Description |
|---|---|
void |
act()
Reverses the direction of this actor.
|
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.
|
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.
|
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 grgr - 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 actornewLocation - the new locationpublic void act()
Actor to define types of actors with different behavior