
/**
 * models three different types of flight reservation
 */

import java.io.* ;
import java.lancs.* ;
import java.util.* ;

class Reservation
    {
    private int flightNumber ;
    private Date dateOfTravel ;
    private int seatNumber ;

    public void readRes() throws IOException
	{
	BasicIo.prompt("Flight number?: ") ;
	flightNumber = BasicIo.readInteger() ;
	BasicIo.prompt("Seat number?: ") ;
	seatNumber = BasicIo.readInteger() ;
	} // end of method readRes
    } // end of class Reservation

class BasicReservation extends Reservation
    {
    } // end of class BasicReservation

class NiceReservation extends Reservation
    {
    public static final int AISLE = 1, WINDOW = 2 ;
    public static final int GREEN = 1, WHITE = 2, RED = 3 ;

    private int seatSort ;
    private int food ;

    public void readNr() throws IOException
	{
	readRes() ;
	BasicIo.prompt("kind of food? 1 (green), 2 (white), 3 (red): ") ;
	food = BasicIo.readInteger() ;
	BasicIo.prompt("kind of seat? 1 (aisle), 2 (window): ") ;
	seatSort = BasicIo.readInteger() ;
	} // end of method readNr
    } // end of class NiceReservation

class PoshReservation extends NiceReservation
    {
    private String destination ;

    public void readPr() throws IOException
	{
	readNr() ;
	BasicIo.prompt("Destination address?: ") ;
	destination = BasicIo.readString() ;
	} // end of method readPr
    } // end of class PoshReservation
    
public class Chapter12n2
    {
    public static void main(String[] args) throws IOException
	{
	System.out.println("res1: Basic") ;
	BasicReservation res1 = new BasicReservation() ;
	res1.readRes() ;
	System.out.println() ;

	System.out.println("res2: Nice") ;
	NiceReservation res2 = new NiceReservation() ;
	res2.readNr() ;
	System.out.println() ;

	System.out.println("res3: Posh") ;
	PoshReservation res3 = new PoshReservation() ;
	res3.readPr() ;
	} // end of main method
    } // end of class Chapter12n2


