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