Class NavigationalAide

java.lang.Object
  extended by NavigationalAide

public class NavigationalAide
extends java.lang.Object

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.

Version:
18 January 2009
Author:
Alyce Brady

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

NavigationalAide

public NavigationalAide(AquaFish fish)
The NavigationalAide constructor sets properties of the fish. Precondition: the aquarium must be big enough to accomodate the biggest fish (currently 75 pixels long and 30 pixels high) plus 10 pixels of padding in all four directions.

Parameters:
fish - the fish whose size and location this aide is keeping track of
Method Detail

centerpointX

public int centerpointX()
Gets the x coordinate in the aquarium of the fish's centerpoint.

Returns:
the x coordinate of the fish's centerpoint

centerpointY

public int centerpointY()
Gets the y coordinate in the aquarium of the fish's centerpoint.

Returns:
the y coordinate of the fish's centerpoint

fishAtBottom

public boolean fishAtBottom()
Determine whether the fish is at the bottom. A fish is considered at the bottom if it cannot descend; in other words, if the distance from the center of the fish to the bottom is less than the fish's height.

Returns:
true if fish is at the bottom; false otherwise

fishAtSurface

public boolean fishAtSurface()
Determine whether the fish is at the surface. A fish is considered at the surface if it cannot ascend; in other words, if the distance from the center of the fish to the surface is less than the fish's height.

Returns:
true if fish is at the surface; false otherwise

fishDistanceToWall

protected int fishDistanceToWall()
Compute how far the fish is from the wall in front of it.

Returns:
distance from front of fish to facing wall

fishHeight

public int fishHeight()
Gets the height of the fish.

Returns:
fish height

fishLength

public int fishLength()
Gets the length of the fish.

Returns:
fish length

halfFishHeight

public int halfFishHeight()
Gets half the height of the fish.

Returns:
half the fish height (rounded if necessary)

halfFishLength

public int halfFishLength()
Gets half the length of the fish.

Returns:
half the fish length (rounded if necessary)

isFishFacingRight

public boolean isFishFacingRight()
Determines whether the fish is facing right.

Returns:
true if fish is facing right; false otherwise

moveFishLeft

protected void moveFishLeft(int distance)
Moves the fish distance units to the left.

Parameters:
distance - distance to move left

moveFishRight

protected void moveFishRight(int distance)
Moves the fish distance units to the right.

Parameters:
distance - distance to move right

raiseFish

protected void raiseFish(int distance)
Moves the fish distance units up.

Parameters:
distance - distance to move up

sinkFish

protected void sinkFish(int distance)
Moves the fish distance units down.

Parameters:
distance - distance to move down

toString

public java.lang.String toString()
This function is provided primarily for debugging purposes.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of a fish