package directory;

import java.util.Hashtable;
import java.util.Enumeration;
import java.io.*;

public class SimpleDirectory {

    // create PrintWriter object for class
    protected static PrintWriter myOut = new PrintWriter (System.out, true);

    // create Hashtable object
    protected Hashtable<Object, Object> table;

    // constructor
    SimpleDirectory () {
        table = new Hashtable<Object, Object>();
    }

    // methods
    // add a name-number entry
    public void add (String name, String number) {
        table.put (name, number);
    }

    // retrieve the number for a name
    public String lookup (String name) {
        return (String) table.get(name);
    }

    // print all names
    public void printNames () {
        myOut.println ("The names in the directory are: ");
        for (Enumeration e = table.keys(); e.hasMoreElements() ;) {
            myOut.println ("   " + e.nextElement());
        }        
    }
}
