Class SlowFish
java.lang.Object
|
+--Fish
|
+--SlowFish
- All Implemented Interfaces:
- Locatable
- public class SlowFish
- extends Fish
AP® Computer Science Marine Biology Simulation:
The SlowFish class represents a fish in the Marine Biology
Simulation that moves very slowly. It moves so slowly that it only has
a 1 in 5 chance of moving out of its current cell into an adjacent cell
in any given timestep in the simulation. When it does move beyond its
own cell, its movement behavior is the same as for objects of the
Fish class.
SlowFish objects inherit instance variables and much of
their behavior from the Fish class.
The SlowFish class is
copyright© 2002 College Entrance Examination Board
(www.collegeboard.com).
- Version:
- 1 July 2002
| Methods inherited from class Fish |
act, breed, changeDirection, changeLocation, color, die, direction, emptyNeighbors, environment, id, isInEnv, location, move, randomColor, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
SlowFish
public SlowFish(Environment env,
Location loc)
- Constructs a slow fish at the specified location in a
given environment. This slow fish is colored red.
(Precondition: parameters are non-null;
loc is valid
for env.)
- Parameters:
env - environment in which fish will liveloc - location of the new fish in env
SlowFish
public SlowFish(Environment env,
Location loc,
Direction dir)
- Constructs a slow fish at the specified location and direction in a
given environment. This slow fish is colored red.
(Precondition: parameters are non-null;
loc is valid
for env.)
- Parameters:
env - environment in which fish will liveloc - location of the new fish in envdir - direction the new fish is facing
SlowFish
public SlowFish(Environment env,
Location loc,
Direction dir,
java.awt.Color col)
- Constructs a slow fish of the specified color at the specified
location and direction.
(Precondition: parameters are non-null;
loc is valid
for env.)
- Parameters:
env - environment in which fish will liveloc - location of the new fish in envdir - direction the new fish is facingcol - color of the new fish
generateChild
protected void generateChild(Location loc)
- Creates a new slow fish.
- Overrides:
generateChild in class Fish
- Parameters:
loc - location of the new fish
nextLocation
protected Location nextLocation()
- Finds this fish's next location. A slow fish moves so
slowly that it might not move out of its current cell in
the environment.
- Overrides:
nextLocation in class Fish
- Following copied from class:
Fish
- Returns:
- the next location for this fish
Copyright© 2002 College Entrance Examination Board