|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.collegeboard.gridworld.actor.Actor
com.collegeboard.gridworld.actor.Critter
public class Critter
A critter is an actor that moves through its world, processing its neighbors in some way and then picking a new location. Override this class to obtain critters with interesting behavior.
copyright© 2005 Cay S. Horstmann (http://horstmann.com)
| Constructor Summary | |
|---|---|
Critter()
|
|
| Method Summary | |
|---|---|
void |
act()
A critter acts by getting a list of its neighbors, processing them, getting locations to move to, selecting one of them, and moving to the selected location. |
ArrayList<Location> |
getMoveLocations()
Get the possible locations for the next move. |
ArrayList<Actor> |
getNeighbors()
Get the neighbors for processing. |
void |
processNeighbors(ArrayList<Actor> neighbors)
Process the critter's neighbors. |
Location |
selectMoveLocation(ArrayList<Location> locs)
Selects the location for the next move. |
| Methods inherited from class com.collegeboard.gridworld.actor.Actor |
|---|
getColor, getDirection, getGrid, getLocation, moveTo, putSelfInGrid, removeSelfFromGrid, setColor, toString, turnBy |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Critter()
| Method Detail |
|---|
public void act()
act in class Actorpublic ArrayList<Actor> getNeighbors()
public void processNeighbors(ArrayList<Actor> neighbors)
neighbors - the neighbors to be processedpublic ArrayList<Location> getMoveLocations()
public Location selectMoveLocation(ArrayList<Location> locs)
locs - the possible locations for the next move
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||