Warning: include(/home/mathwa6/public_html/php_include/forum_left_side.php) [function.include]: failed to open stream: No such file or directory in /home/mathwa6/public_html/php_include/ontheLeft_moris.php on line 296
Warning: include() [function.include]: Failed opening '/home/mathwa6/public_html/php_include/forum_left_side.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/mathwa6/public_html/php_include/ontheLeft_moris.php on line 296
|
Cops and Robbers 
Critter Sub Class Assignments
import info.gridworld.actor.Critter ;
Directly from the mouths of the College Board:
It is usually not a good idea to override the act method in a Critter subclass. The Critter class was designed to represent actors that process other actors and then move. If the act method is unsuitable for your actors, you should consider extendig Actor, not Critter.
- public ArrayList<Actor> getActors()
- Postcondition
- 1) CANNOT change the state of the actors
- public processActors(ArrayList<Actor> actors
- PostConditions
- 1) State of all actors in the grid other than this critter and the elements of actors is unchanged (You can only mess with this critter and with ArrayList paramater).
- 2) location of this critter is unchanged
- public ArrayList<Location> getMoveLocations()
- Postcondition
- 1) state o all actors is unchanged
- public ArrayList<Location> SelectMoveLocations()
- Postconditions
- 1) Returned location is an element of locs, this critter's current location, or null
- 2) the state of all actors is unchanged
- public ArrayList<Location> getMoveLocations()
- public void MakeMove(Location loc)
- Postconditions
- 1) getLocation() == loc
- 2) state of all actors other than those at the old and new locations are unchanged
Robber class
A Robber is a Critter. The cop is not smart and moves one square at a time. This robber is a coward and does not shoot or kill.
processActors()
- steals() money, jewels, cars.
- The robber steals whenever he is adjacent to these items.
- Stealing means moving to that spot
Cop class
A Cop is a Critter. The cop is smart moves two squares at a time.
processActors()
- catches/arrests Robbers
- money, cars, jewels are left alone(walk around them)
Non Critter Class

- money and jewels: do nothing
- car: if a robber tries to steal the car either alarm goes off or it is stolen.
|