Class SlowFish
java.lang.Object
|
+--Fish
|
+--SlowFish
- All Implemented Interfaces:
- Locatable
- public class SlowFish
- extends Fish
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 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.
| Methods inherited from class Fish |
act, changeDirection, changeLocation, color, 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 and
dir are 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 and
dir are 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.
- 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 may 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