001package edu.pdx.cs410J.core;
002
003import edu.pdx.cs410J.lang.*;
004import java.util.*;
005
006/**
007 * This classes demonstrates <code>Map</code>s in the collection
008 * classes.
009 */
010public class Farm {
011
012  /**
013   * Prints the contents of a <code>Map</code>.
014   */
015  private static void print(Map<String, Animal> map) {
016    for (String key : map.keySet()) {
017      Object value = map.get(key);
018
019      String s = key + " -> " + value;
020      System.out.println(s);
021    }
022  }
023
024  /**
025   * Create a <code>Map</code> and print it.
026   */
027  public static void main(String[] args) {
028    Map<String, Animal> farm = new HashMap<String, Animal>();
029    farm.put("Old MacDonald", new Human("Old MacDonald"));
030    farm.put("Bossie", new Cow("Bossie"));
031    farm.put("Clyde", new Sheep("Clyde"));
032    farm.put("Louise", new Duck("Louise"));
033
034    print(farm);
035  }
036
037}