first commit
This commit is contained in:
99
CS1322/final/Animals/Aquarium.java
Normal file
99
CS1322/final/Animals/Aquarium.java
Normal file
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* <PRE>
|
||||
* Aquarium.java
|
||||
*
|
||||
* Revisions: 1.0 Sep. 26, 2002
|
||||
* Created the Aquarium class
|
||||
* 1.1 Sep. 28, 2002
|
||||
* Finished, Compiled, Commented
|
||||
*
|
||||
* </PRE>
|
||||
*
|
||||
* Collaboration Statement:
|
||||
* I worked on the homework assignment alone, using only
|
||||
* course materials.
|
||||
*
|
||||
* Created with JCreatorLE, some indents are off when viewed through notepad
|
||||
* or EMACS
|
||||
*
|
||||
* @author <A HREF="mailto:gtg184g@mail.gatech.edu">Jose Manuel Caban</A>
|
||||
* @version Version 1.1, Sep. 28, 2002
|
||||
*/
|
||||
|
||||
public class Aquarium extends ZooBuilding{
|
||||
|
||||
////////////////
|
||||
//Constructors//
|
||||
////////////////
|
||||
|
||||
/**
|
||||
*Constructor for Aquarium
|
||||
*@param name the name for the Aquarium
|
||||
*/
|
||||
public Aquarium(String name){
|
||||
super(name);
|
||||
}
|
||||
|
||||
///////////
|
||||
//Methods//
|
||||
///////////
|
||||
|
||||
/**
|
||||
*@return true if it is safe to enter
|
||||
*Safe if all dangerous animals are 30 feet underwater
|
||||
*/
|
||||
public boolean isSafeToEnter(){
|
||||
Animal aTemp;
|
||||
SwimmingType sTemp;
|
||||
boolean bSafe = true;
|
||||
for(int i=0; i<getTheAnimals().size(); i++){
|
||||
aTemp = (Animal)getTheAnimals().removeFromBack();
|
||||
sTemp = (SwimmingType)aTemp;
|
||||
if(aTemp.isDangerous() && sTemp.getDepth() < 30){
|
||||
bSafe = false;
|
||||
}
|
||||
getTheAnimals().addToFront(aTemp);
|
||||
}
|
||||
return bSafe;
|
||||
}
|
||||
|
||||
/**
|
||||
*override default string method for use with this program
|
||||
*/
|
||||
public String toString(){
|
||||
return ("An Aquarium named " + getName() + ".");
|
||||
}
|
||||
|
||||
/****************************************************/
|
||||
|
||||
/**
|
||||
* Debugging main for class Aquarium.
|
||||
* This method will rigorously test my code.
|
||||
*
|
||||
* <br><br>
|
||||
* @param args a String array of command line arguments.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Aquarium swimswim = new Aquarium("Smells like Fish");
|
||||
|
||||
swimswim.getTheAnimals().addToFront(new Duck("Bob"));
|
||||
swimswim.getTheAnimals().addToBack(new Gator("Crocodile"));
|
||||
swimswim.getTheAnimals().addToFront(new GoldFish("Can't Remember Jack",5));
|
||||
|
||||
swimswim.getTheAnimals().listOut();
|
||||
System.out.println();
|
||||
|
||||
Gator Tom = (Gator)swimswim.getTheAnimals().getLast();
|
||||
Tom.setDepth(50);
|
||||
|
||||
System.out.println(swimswim.isSafeToEnter());
|
||||
Tom.setDepth(4);
|
||||
System.out.println(swimswim.isSafeToEnter());
|
||||
|
||||
swimswim.getTheAnimals().listOut();
|
||||
|
||||
System.out.println(swimswim);
|
||||
|
||||
}// end of main(String[] args)
|
||||
|
||||
}// end of class Aquarium
|
||||
Reference in New Issue
Block a user