|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.collegeboard.gridworld.actor.Actor
public abstract class Actor
An Actor is an entity with a color and direction
that can act.
copyright© 2005 Cay S. Horstmann (http://horstmann.com)
| Constructor Summary | |
|---|---|
Actor()
Constructs a black actor that is facing north. |
|
| Method Summary | |
|---|---|
abstract void |
act()
Override this method to define the action 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 Precondition: This actor is in a grid |
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 an actor from a grid. |
void |
setColor(Color newColor)
Sets the color of this actor. |
String |
toString()
|
void |
turnBy(int angle)
Turns the direction of this actor. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Actor()
| Method Detail |
|---|
public abstract void act()
public Location getLocation()
public Grid<Actor> getGrid()
public void putSelfInGrid(Grid<Actor> gr,
Location loc)
gr - the grid into which this actor should be placedloc - the location into which the actor should be placed (must be valid)public void removeSelfFromGrid()
public void moveTo(Location newLocation)
newLocation - the new location (must be valid)public void turnBy(int angle)
angle - the angle (clockwise) by which to turnpublic int getDirection()
public Color getColor()
public void setColor(Color newColor)
newColor - the new colorpublic String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||