Class PetList

java.lang.Object
  |
  +--PetList

public class PetList
extends java.lang.Object

This class is a collection of animals of various types. It manages the collection by having all the various animals do various things upon request.


Constructor Summary
PetList(double food)
          This default constructor creates the new animal objects, using the "new" operator and the appropriate constructors.
 
Method Summary
 void dine()
          Everybody in the set eats a large meal.
static void main(java.lang.String[] args)
          This is a simple test harness for this class.
 void sleep()
          Everybody in the set sleeps it all off.
 void snack()
          Everybody in the set eats a small meal.
 void speak()
          This method calls the noise-making method for each animal object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PetList

public PetList(double food)
This default constructor creates the new animal objects, using the "new" operator and the appropriate constructors. References to the new animal objects are stored in instance variables of the PetList object.
Parameters:
food - total amount of food available in pounds
Method Detail

snack

public void snack()
Everybody in the set eats a small meal. This method calls the eat(food) method of each of the animal objects. The amount of food provided to each animal is the same as the defined meal size for that animal, or the remaining amount of food, which ever is less.

dine

public void dine()
Everybody in the set eats a large meal. This method calls the eat(food) method of each of the animal objects. The amount of food provided to each animal is twice the amount of the defined meal size for that animal. After the meal, we throw away all the food that was provided to the animal, regardless of whether or not it was eaten.

sleep

public void sleep()
Everybody in the set sleeps it all off. This method calls the sleep() method of each of the animal objects.

speak

public void speak()
This method calls the noise-making method for each animal object.

main

public static void main(java.lang.String[] args)
This is a simple test harness for this class.
Parameters:
args - ignored