Class BasicAnimal

java.lang.Object
  |
  +--BasicAnimal
All Implemented Interfaces:
Animal
Direct Known Subclasses:
Cat, Dog, Sparrow

public abstract class BasicAnimal
extends java.lang.Object
implements Animal

The base class for several types of Animals. Does not implement the noise method of the Animal interface, hence must be abstract.


Field Summary
protected  double currentWeight
          the weight of this animal in pounds.
protected  double mealSize
          the serving size of one meal for this animal in pounds.
protected  java.lang.String name
          the name of this animal.
 
Constructor Summary
BasicAnimal(java.lang.String theName, double serving, double weight)
          Create a new BasicAnimal, using supplied parameter values.
 
Method Summary
 void eat(double pounds)
          Eat some goodies.
 double getMealSize()
          get the meal size defined for this animal.
 void sleep()
          Provide this animal with a way to rest when weary.
 java.lang.String toString()
          print information about this animal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Animal
noise
 

Field Detail

mealSize

protected double mealSize
the serving size of one meal for this animal in pounds.

currentWeight

protected double currentWeight
the weight of this animal in pounds.

name

protected java.lang.String name
the name of this animal.
Constructor Detail

BasicAnimal

public BasicAnimal(java.lang.String theName,
                   double serving,
                   double weight)
Create a new BasicAnimal, using supplied parameter values.
Parameters:
theName - name of this animal
serving - the size of a single meal for this animal in pounds
weight - the initial weight of this animal in pounds
Method Detail

sleep

public void sleep()
Provide this animal with a way to rest when weary.
Specified by:
sleep in interface Animal

eat

public void eat(double pounds)
Eat some goodies. There is some weight gain after eating.
Specified by:
eat in interface Animal
Parameters:
pounds - the number of pounds of food provided.

getMealSize

public double getMealSize()
get the meal size defined for this animal.
Specified by:
getMealSize in interface Animal
Returns:
meal size in pounds

toString

public java.lang.String toString()
print information about this animal.
Overrides:
toString in class java.lang.Object
Returns:
the string description of this animal