// HouseTest1A.java
//
// Tests constructor, get methods, and toString
// Handles exceptions

import java.util.StringTokenizer;

public class HouseTest1A
{
   public static void main(String[] args)
   {
      if ( args.length == 0 )
      {
         System.out.println("Filename of data file needed"
                            + " as command-line argument");
         System.exit(0);
      }  // if

      TextFileInput in = new TextFileInput(args[0]);

      while ( true )
      {
         String line = in.readLine();
         if ( line == null )
            break;
         testHouse(line);
      }  // while
   }  // method main

   public static void testHouse(String line)
   {
      try
      {
         System.out.println("Will now try to instantiate: " + line);
         StringTokenizer st = new StringTokenizer(line, "|");
         String zipCode = st.nextToken();
         int price = Integer.parseInt(st.nextToken());
         int numberOfRooms = Integer.parseInt(st.nextToken());
         House house = new House(zipCode, price, numberOfRooms);
         System.out.println("Instantiated: " + house);
         System.out.println("   zipCode=" + house.getZipCode()
                            + " price=" + house.getPrice()
                            + " numberOfRooms="
                            + house.getNumberOfRooms());
      }  // try
      catch ( RuntimeException re )
      {
         re.printStackTrace();
      }  // catch
   }  // method testHouse
}  // class HouseTest1A