Class Aquarium

java.lang.Object
  extended by Aquarium

public class Aquarium
extends java.lang.Object

Aquarium Lab Series:
The Aquarium class defines an Aquarium and its properties.

Created:
10 July 2002, Alyce Brady

Modifications:
22 March 2008, Alyce Brady, Added randomCenterX and randomCenterY methods, moving that logic from the old AquaFish class to the Aquarium class. 23 March 2008, Alyce Brady, Added list of fish to the aquarium to simplify the display of an aquarium containing fish.

Version:
23 March 2008
Author:
Alyce Brady

Constructor Summary
Aquarium(int width, int height)
          Constructs an Aquarium with user-specified size.
 
Method Summary
 void add(AquaFish fish)
          Adds the given fish to this aquarium.
 java.awt.Color color()
          Determines the color of the aquarium (water color).
 java.util.ArrayList<AquaFish> getFish()
          Returns a list of the fish in this aquarium.
 int height()
          Determines the height of the aquarium.
 int randomCenterX(int objectLength)
          Determines a valid random x coordinate for the centerpoint of an object with the given length along the x axis.
 int randomCenterY(int objectHeight)
          Determines a valid random y coordinate for the centerpoint of an object with the given width or height along the y axis.
 boolean validLoc(int xCoord, int yCoord)
          Determines whether the given coordinates specify a valid location (one that exists within the bounds of the aquarium).
 int width()
          Determines the width of the aquarium.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Aquarium

public Aquarium(int width,
                int height)
Constructs an Aquarium with user-specified size.

Parameters:
width - width of the aquarium when displayed (in pixels)
height - height of the aquarium when displayed (in pixels)
Method Detail

add

public void add(AquaFish fish)
Adds the given fish to this aquarium.


color

public java.awt.Color color()
Determines the color of the aquarium (water color).


getFish

public java.util.ArrayList<AquaFish> getFish()
Returns a list of the fish in this aquarium.


height

public int height()
Determines the height of the aquarium.


randomCenterX

public int randomCenterX(int objectLength)
Determines a valid random x coordinate for the centerpoint of an object with the given length along the x axis. Precondition: this aquarium must be big enough to accomodate the object with the given length, plus 10 pixels of padding in each direction.


randomCenterY

public int randomCenterY(int objectHeight)
Determines a valid random y coordinate for the centerpoint of an object with the given width or height along the y axis. Precondition: this aquarium must be big enough to accomodate the object with the given height, plus 10 pixels of padding above and below.


validLoc

public boolean validLoc(int xCoord,
                        int yCoord)
Determines whether the given coordinates specify a valid location (one that exists within the bounds of the aquarium).


width

public int width()
Determines the width of the aquarium.