java.lang.ObjectAquarium
public class Aquarium
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.
| 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 |
|---|
public Aquarium(int width,
int height)
width - width of the aquarium when displayed (in pixels)height - height of the aquarium when displayed (in pixels)| Method Detail |
|---|
public void add(AquaFish fish)
public java.awt.Color color()
public java.util.ArrayList<AquaFish> getFish()
public int height()
public int randomCenterX(int objectLength)
public int randomCenterY(int objectHeight)
public boolean validLoc(int xCoord,
int yCoord)
public int width()