java.lang.ObjectAquaFish
public class AquaFish
Aquarium Lab Series:
The AquaFish class defines a fish in an aquarium.
Created:
10 July 2002, Alyce Brady
Modifications:
22 March 2008, Alyce Brady, Simplified by removing references to
AquaPoint and Direction classes and moving
calculation of valid random starting locations
to the Aquarium class.
23 March 2008, Alyce Brady, Modified to put some of the more complex
methods in the NavigationAide class, to make
the AquaFish class easier to read.
(date), (your name), Modified to ....
Aquarium| Field Summary | |
|---|---|
static int |
MAX_DISTANCE
|
static int |
MIN_DISTANCE
|
| Constructor Summary | |
|---|---|
AquaFish(Aquarium aqua)
The AquaFish constructor sets properties of the AquaFish. |
|
| Method Summary | |
|---|---|
Aquarium |
aquarium()
Gets the aquarium in which this fish moves. |
boolean |
atWall()
Determine whether this fish is at a wall. |
void |
changeDir()
Reverses direction. |
java.awt.Color |
color()
Gets fish's color. |
boolean |
facingLeft()
Determines whether this fish is facing left. |
boolean |
facingRight()
Determines whether this fish is facing right. |
int |
height()
Gets the height of this fish. |
int |
id()
Gets the unique identifier for this fish. |
int |
length()
Gets the length of this fish. |
void |
moveForward()
Moves forward horizontally by random increments, staying within the aquarium. |
java.lang.String |
toString()
This function is provided primarily for debugging purposes. |
int |
xCoord()
Gets this fish's x coordinate in the aquarium. |
int |
yCoord()
Gets this fish's y coordinate in the aquarium. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX_DISTANCE
public static final int MIN_DISTANCE
| Constructor Detail |
|---|
public AquaFish(Aquarium aqua)
aqua - the Aquarium in which to place the fish| Method Detail |
|---|
public Aquarium aquarium()
public boolean atWall()
public void changeDir()
public java.awt.Color color()
public boolean facingLeft()
true if fish is facing left;
false otherwisepublic boolean facingRight()
true if fish is facing right;
false otherwisepublic int height()
public int id()
public int length()
public void moveForward()
public java.lang.String toString()
toString in class java.lang.Objectpublic int xCoord()
public int yCoord()