// Computer Science Example
// Inheritance

import java.io.*;

public class TestPolicy
{
     public static void main (String [] args)
     {
          try
          {
               BufferedReader infile = new BufferedReader (new InputStreamReader (new FileInputStream ("infile.txt")));
               LifePolicy lifeIns = new LifePolicy ();
               lifeIns.readPolicy (infile);
               lifeIns.displayPolicy ();
               CarPolicy carIns = new CarPolicy ();
               carIns.readPolicy (infile);
               carIns.displayPolicy ();
          } catch (IOException e) {}
     }
} // class TestPolicy

class Policy
{
     protected String id, owner;
 
     public void readPolicy (BufferedReader infile) throws IOException
     {
          id = infile.readLine ();
          owner = infile.readLine ();
     } // method readPolicy
 
     public void displayPolicy ()
     {
          System.out.println ("The owner is " + owner);
          System.out.println ("The ID is " + id);
     } // method displayPolicy
} // class Policy

class CarPolicy extends Policy
{
     private String make, model;
     private int year;
 
     public void readPolicy (BufferedReader infile) throws IOException
     {
          super.readPolicy (infile);
          make = infile.readLine ();
          model = infile.readLine ();
          year = Integer.parseInt (infile.readLine ());
     } // method readPolicy
 
     public void displayPolicy ()
     {
          super.displayPolicy ();
          System.out.println ("The make of the car is " + make);
          System.out.println ("The model of the car is " + model);
          System.out.println ("The year is " + year);
     } // method displayPolicy
} // class CarPolicy

class LifePolicy extends Policy
{
 private String beneficiary;
 private double policyValue;
 
     public void readPolicy (BufferedReader infile) throws IOException
     {
          super.readPolicy (infile);
          beneficiary = infile.readLine ();
          policyValue = Double.valueOf (infile.readLine ()).doubleValue ();
     } // method readPolicy
 
     public void displayPolicy ()
     {
          super.displayPolicy ();
          System.out.println ("The beneficiary is " + beneficiary);
          System.out.println ("The policy value is " + policyValue);
     } // method displayPolicy
} // class LifePolicy