001package edu.pdx.cs410J.lang;
002
003/**
004 * This class has a main method that demonstrates the effects of
005 * inheritance and virtual method dispatches using the animal class
006 * hierarchy.
007 */
008public class SayWhat {
009
010  private static Human human;
011  private static Cow cow;
012  private static Ant ant;
013
014  /**
015   * Prints an animal's name and what it says.
016   */
017  private static void saysWhat(Animal animal) {
018    System.out.println(animal.getName() + " says \"" +
019                       animal.says() + "\"");
020  }
021
022  /**
023   * This main method creates a number of animals and prints out their
024   * names and what they say.
025   */
026  public static void main(String[] args) {
027    human = new Human("Dave");
028    cow = new Cow("Bessy");
029    ant = new Ant("Arthur");
030
031    saysWhat(human);
032    saysWhat(cow);
033    saysWhat(ant);
034  }
035
036}