|
|||||||||
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
Constructor Summary | |
---|---|
Actor()
Constructs a black actor that is facing north. |
Method Summary | |
---|---|
abstract void |
act()
Override this method with the action that your actor carries out.actor needs to |
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 |
ArrayList<Location> |
getValidNeighborLocations()
Gets the valid locations of the neighbors in all directions (north, northeast, east, southeast, south, southwest, west, and northwest) 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 |
turn(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 Location getLocation()
public ArrayList<Location> getValidNeighborLocations()
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 abstract void act()
public void turn(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 |