gridWorldTest
Class ChameleonCritter

java.lang.Object
  extended by info.gridworld.actor.Actor
      extended by info.gridworld.actor.Critter
          extended by gridWorldTest.ChameleonCritter

public class ChameleonCritter
extends Critter

A ChameleonCritter takes on the color of neighboring actors as it moves through the grid.
The implementation of this class is testable on the AP CS A and AB exams.


Constructor Summary
ChameleonCritter()
           
 
Method Summary
 void makeMove(Location loc)
          Turns towards the new location as it moves.
 void processActors(java.util.ArrayList<Actor> actors)
          Randomly selects a neighbor and changes this critter's color to be the same as that neighbor's.
 
Methods inherited from class info.gridworld.actor.Critter
act, getActors, getMoveLocations, selectMoveLocation
 
Methods inherited from class info.gridworld.actor.Actor
getColor, getDirection, getGrid, getLocation, moveTo, putSelfInGrid, removeSelfFromGrid, setColor, setDirection, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChameleonCritter

public ChameleonCritter()
Method Detail

processActors

public void processActors(java.util.ArrayList<Actor> actors)
Randomly selects a neighbor and changes this critter's color to be the same as that neighbor's. If there are no neighbors, no action is taken.

Overrides:
processActors in class Critter
Parameters:
actors - the actors to be processed

makeMove

public void makeMove(Location loc)
Turns towards the new location as it moves.

Overrides:
makeMove in class Critter
Parameters:
loc - the location to move to