

/**
 * Exercises the ZooAnimal hierarchy.
 */
public class ZooAnimalTester {
  public static void main(String[] args) {
    ZooAnimal[] animals = new ZooAnimal[4];

    animals[0] = new Eagle("Eric");
    animals[1] = new Platypus("Patrick");
    animals[2] = new Bat("Beatrice");
    animals[3] = new Shark("Sally");

    // iterate over array; if hungry, then call eat
    for (int i = 0; i < animals.length; i++) {
      if (animals[i].isHungry()) {
        animals[i].eat();
      }
    }

    // only Patrick the Platypus eats, since he is the only animal that is
    //   hungry; nothing is printed for animals that aren't hungry

  } // main
} // ZooAnimalTester