java.lang.ObjectNavigationalAide
public class NavigationalAide
Aquarium Lab Series:
The NavigationalAide class defines some of the more complex methods
for keeping track of a fish's size and location in an aquarium.
Created:
23 March 2008, Alyce Brady, from the previous version of AquaFish.
Modifications:
18 January 2009, Alyce Brady, moved determination of direction to AquaFish.
Constructor Summary | |
---|---|
NavigationalAide(AquaFish fish)
The NavigationalAide constructor sets properties of the fish. |
Method Summary | |
---|---|
int |
centerpointX()
Gets the x coordinate in the aquarium of the fish's centerpoint. |
int |
centerpointY()
Gets the y coordinate in the aquarium of the fish's centerpoint. |
boolean |
fishAtBottom()
Determine whether the fish is at the bottom. |
boolean |
fishAtSurface()
Determine whether the fish is at the surface. |
protected int |
fishDistanceToWall()
Compute how far the fish is from the wall in front of it. |
int |
fishHeight()
Gets the height of the fish. |
int |
fishLength()
Gets the length of the fish. |
int |
halfFishHeight()
Gets half the height of the fish. |
int |
halfFishLength()
Gets half the length of the fish. |
boolean |
isFishFacingRight()
Determines whether the fish is facing right. |
protected void |
moveFishLeft(int distance)
Moves the fish distance units to the left. |
protected void |
moveFishRight(int distance)
Moves the fish distance units to the right. |
protected void |
raiseFish(int distance)
Moves the fish distance units up. |
protected void |
sinkFish(int distance)
Moves the fish distance units down. |
java.lang.String |
toString()
This function is provided primarily for debugging purposes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NavigationalAide(AquaFish fish)
fish
- the fish whose size and location this aide is
keeping track ofMethod Detail |
---|
public int centerpointX()
public int centerpointY()
public boolean fishAtBottom()
true
if fish is at the bottom;
false
otherwisepublic boolean fishAtSurface()
true
if fish is at the surface;
false
otherwiseprotected int fishDistanceToWall()
public int fishHeight()
public int fishLength()
public int halfFishHeight()
public int halfFishLength()
public boolean isFishFacingRight()
true
if fish is facing right;
false
otherwiseprotected void moveFishLeft(int distance)
distance
units to the left.
distance
- distance to move leftprotected void moveFishRight(int distance)
distance
units to the right.
distance
- distance to move rightprotected void raiseFish(int distance)
distance
units up.
distance
- distance to move upprotected void sinkFish(int distance)
distance
units down.
distance
- distance to move downpublic java.lang.String toString()
toString
in class java.lang.Object