java.lang.Object AquaFish
public class AquaFish
Aquarium Lab Series:
The AquaFish class defines a fish in an aquarium. A fish of this
class can move in the aquarium (always staying fully within the aquarium),
and can report its color, dimensions, and location, for the purpose of
the display.
Created:
10 July 2002, Alyce Brady
Modifications:
2008-2009, Alyce Brady, Simplified by replacing two classes
(AquaPoint and Direction) with single
NavigationAide class.
(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. |
|
AquaFish(Aquarium aqua,
java.awt.Color newColor)
The AquaFish constructor sets properties of the AquaFish. |
Method Summary | |
---|---|
Aquarium |
aquarium()
Gets the aquarium in which this fish lives. |
boolean |
atWall()
Determine whether this fish is at a wall. |
void |
changeDir()
Reverses direction. |
java.awt.Color |
color()
Gets fish's color. |
int |
height()
Gets the height of this fish. |
int |
id()
Gets the unique identifier for this fish. |
boolean |
isFacingLeft()
Determines whether this fish is facing left. |
boolean |
isFacingRight()
Determines whether this fish is facing right. |
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 the fish will livepublic AquaFish(Aquarium aqua, java.awt.Color newColor)
aqua
- the Aquarium in which the fish will livenewColor
- the color for the new fishMethod Detail |
---|
public Aquarium aquarium()
public boolean atWall()
public void changeDir()
public java.awt.Color color()
public int height()
public int id()
public boolean isFacingLeft()
true
if fish is facing left;
false
otherwisepublic boolean isFacingRight()
true
if fish is facing right;
false
otherwisepublic int length()
public void moveForward()
public java.lang.String toString()
toString
in class java.lang.Object
public int xCoord()
public int yCoord()