import java.io.*;
import java.util.*;


/**
 * A driver that can be used to test the LengthDatabase class
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0  
 */
public class DatabaseDriver1
{
    /**
     * The entry point of the application
     *
     * @param args   The command line arguments
     */
    public static void main(String[] args) throws IOException
    {
       Length                  aLength, result;
       LengthDatabase          database;
       Scanner                 scanner;        
       String                  name, prompt;

       prompt   = "\nName to look for (Ctrl-Z to exit): ";       
       database = new LengthDatabase();

       aLength = new Length(5, 8);
       database.add("Mike", aLength);

       aLength = new Length(6, 2);
       database.add("Bill", aLength);

       aLength = new Length(5, 9);
       database.add("Nancy", aLength);

       scanner = new Scanner(System.in);

       System.out.print(prompt);
       while (scanner.hasNext())
       {
          name = scanner.nextLine();
           
          result = database.get(name);
          if (result != null)
          {
             System.out.println(name+" is "+result);
          }
          else
          {
             System.out.println("I don't know how tall "+name+" is.");
          }

          System.out.print(prompt);
       }
    }

}
