Minnow Project

Class Minnow

All Implemented Interfaces:

public class Minnow
extends java.lang.Object
implements Locatable

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)

1 September 2002
See Also:
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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public Minnow(Environment env,
              Location loc)
Constructs a minnow at the specified location in a given environment. The Minnow is assigned a random direction and random color. (Precondition: parameters are non-null; loc is valid for env.)
env - environment in which minnow will live
loc - location of the new minnow in env
Method Detail


public Environment environment()
Returns this minnow's environment.
the environment in which this minnow lives


public java.awt.Color color()
Returns this minnow's color.
the color of this minnow


public Location location()
Returns this minnow's location.
Specified by:
location in interface Locatable
the location of this minnow in the environment


public Direction direction()
Returns this minnow's direction.
the direction in which this minnow is facing


public java.lang.String toString()
Returns a string representing key information about this minnow.
toString in class java.lang.Object
a string indicating the minnow's location and direction


public void act()
Acts for one step in the simulation.

Minnow Project

Copyright© 2002-2003 Alyce Brady