java.lang.Object | +--Minnow
Minnow Program:
The Minnow class represents a simple fish in an environment. It is
similar to, but simpler than, the Fish class in the Marine Biology
Simulation Case Study.
When moving on to the Marine Biology Simulation case study, notice the following differences between the Minnow and Fish classes:
The Fish class has more instance variables and more constructors.
(see pp. 27 - 30 of the MBS case study narrative)
Fish check that they are still in the environment before acting.
(p. 33)
Fish methods use the changeDirection helper method and the
environment, location, and direction accessor methods. (p. 39)
The Fish helper methods are protected, not private. (pp. 30, 65)
Environment,
Direction,
Location| Constructor Summary | |
Minnow(Environment env,
Location loc)
Constructs a minnow at the specified location in a given environment. |
|
| Method Summary | |
void |
act()
Acts for one step in the simulation. |
java.awt.Color |
color()
Returns this minnow's color. |
Direction |
direction()
Returns this minnow's direction. |
Environment |
environment()
Returns this minnow's environment. |
Location |
location()
Returns this minnow's location. |
java.lang.String |
toString()
Returns a string representing key information about this minnow. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Minnow(Environment env,
Location loc)
loc is valid
for env.)
env - environment in which minnow will liveloc - location of the new minnow in env| Method Detail |
public void act()
public java.awt.Color color()
public Direction direction()
public Environment environment()
public Location location()
public java.lang.String toString()
toString in class java.lang.Object