/**
 * Class test code for demonstrating interfaces.
 *
 * @author <a href="mailto:terran@cs.unm.edu">Terran Lane</a>
 * @version 1.0
 */

import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;

public class ITest {
  public static void main(String[] args) {
    Map m;

    m=new TreeMap();
    System.out.println("Filling Map m (HashMap)...");
    _fillin(m);
    System.out.println("Dumping Map m (HashMap):");
    _dump(m);
    System.out.println("Done.");
    m=null;
  }

  /* ******************** end of public interface ******************** */

  /**
   * Populate the Map with the static private data.
   *
   * @param m The <code>Map</code> to populate
   */
  private static void _fillin(Map m) {
    for (int i=0;i<_keys.length;++i) {
      m.put(_keys[i],_vals[i]);
    }
  }

  /**
   * Write the contents of the Map (all key/value pairs) to stdout.  Assumes
   * that all keys and values are Strings.
   *
   * @param m The <code>Map</code> to display.
   */
  private static void _dump(Map m) {
    Set s=m.keySet();
    Iterator i=s.iterator();
    while (i.hasNext()) {
      String k=(String)i.next();
      String v=(String)m.get(k);
      System.out.println("\t" + k + " <=> " + v);
    }
  }

  private static String[] _keys={ "Spirit", "Opportunity", "Beagle" };
  private static String[] _vals={ "Buggy", "Flaky", "Gone" };
}
