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.
|
java.awt.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(java.awt.Color newColor)
Sets the color of this actor.
|
void |
setDirection(int newDirection)
Sets the current direction of this actor.
|
java.lang.String |
toString()
Creates a string that describes this actor.
|
public java.awt.Color getColor()
public void setColor(java.awt.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 actornewLocation
- the new locationpublic void act()
Actor
to define types of actors with different behaviorpublic java.lang.String toString()
toString
in class java.lang.Object