/** *
* Gator.java * * Revisions: 1.0 Sep. 18, 2002 * Created the Gator class * 1.1 Sep. 18, 2002 * Finished the Gator Class * 1.1f Sep. 18, 2002 * Cleaned up equals() to make more readable ** * 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 Jose Manuel Caban * @version Version 1.1f, Sep. 18, 2002 */ public class Gator extends Animal implements SwimmingType{ /** *depth of the gator */ private int depth; //////////////// //Constructors// //////////////// /** *Gator Constructor *@param name the name of the gator *sets depth to 0 */ public Gator(String name){ super(name); this.depth = 0; } /////////////////////// //Accessors/Modifiers// /////////////////////// /** *set the depth of the gator *@param depth the value to be applied */ public void setDepth(int depth){ if(depth > 50){ this.depth = 50; } else { this.depth = depth; } } /** *get the depth of the gator *@return the depth of the gator */ public int getDepth(){ return this.depth; } /////////// //Methods// /////////// /** *Give the dangerous value of the Gator *@return true, the gator is dangerous */ public boolean isDangerous(){ return true; } /** *Have the Gator eat some food *acceptible foods: chicken,beef,pork,human,mystery meat *@param if the food is of the above name, set isHungry to false */ public void eat(String food){ if(food.equals("chicken")){ setIsHungry(false); } else if(food.equals("beef")){ setIsHungry(false); } else if(food.equals("pork")){ setIsHungry(false); } else if(food.equals("human")){ setIsHungry(false); } else if(food.equals("mystery meat")){ setIsHungry(false); } }//end of eat(food) /** *Find the equality of Gator *@param obj the Object to be compared to *@return the equality value */ public boolean equals(Object obj){ if(!(obj instanceof Gator)){ return false; } if(!super.equals(obj)){ return false; } Gator temp = (Gator)obj; if(temp.getDepth() != this.getDepth()){ return false; } return true; }//end of equals(Object) /** * Change standard string to output to be used for this specific program * *