/** *
 *  Animal.java
 *
 *  Revisions: 1.0 Sep. 17, 2002
 *               Created the Animal class
 *			   1.1 Sep. 17, 2002
 *				 Finished the Animal Class
 *
 *  
* * 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.1, Sep. 17, 2002 */ public abstract class Animal { /** *whether or not the animal is hungry */ private boolean isHungry; /** *holds the animal's name */ private String name; //////////////// //Constructors// //////////////// /** *Constructor for Animal *@param name the value to assign name */ public Animal(String name){ this.name = name; isHungry = false; } /////////////////////// //Accessors/Modifiers// /////////////////////// /** *isHungry Modifier *@param h the value applied to isHungry */ public void setIsHungry(boolean h){ isHungry = h; } /** *isHungry Accessor *@return the value of isHungry */ public boolean getIsHungry(){ return isHungry; } /** *Accessor for name *@return the value of name */ public String getName(){ return name; } /////////// //Methods// /////////// /** *@return whether the animal is dangerous or not */ public abstract boolean isDangerous(); /** *Give the animal something to eat *@param food, the food to feed the animal */ public abstract void eat(String food); /** *Equals method *@param the value to test equality with *@return the truthnes of the equality */ public boolean equals(Object obj){ if((obj instanceof Animal) == false){ return false; } Animal temp = (Animal)obj; //added "this." to make it verbose and more readable if(!(temp.getName().equals(this.getName()))){ return false; } if(temp.isDangerous() != this.isDangerous()){ return false; } if(temp.getIsHungry() != this.getIsHungry()){ return false; } return true; } /** * Debugging main for class Animal. * This method will rigorously test my code. * *

* @param args a String array of command line arguments. */ public static void main(String[] args) { //nuttin ta test }// end of main(String[] args) }// end of class Animal