airline
Class Flight.Ticket

java.lang.Object
  extended by airline.Flight.Ticket
Enclosing class:
Flight

public class Flight.Ticket
extends Object

For each passenger on the flight, there is an underlying Ticket that is used to track the seating assignment for the passenger on the flight as well as to trace this passenger back to an original Reservation.

Author:
Michael Goldwasser

Method Summary
 void cancel()
          Officially removes the underlying traveler from the given flight.
 Flight getFlight()
          Returns a reference to the associated Flight.
 String getSeat()
          Returns the string representation of the seat (e.g., "28C").
 String getTravelerName()
          Returns the name of the traveler for this ticket.
 boolean requestSeatChange(String seatDesignator)
          Requests a seat change from the existing assignment to the designated seat.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

cancel

public void cancel()
            throws IllegalArgumentException
Officially removes the underlying traveler from the given flight. This causes the ticket to be invalid, and returns the seat to be empty;

Throws:
IllegalArgumentException - if the Ticket was invalid (for example, if previously removed from flight)

getFlight

public Flight getFlight()
Returns a reference to the associated Flight.

Returns:
Flight instance.

getSeat

public String getSeat()
Returns the string representation of the seat (e.g., "28C").

Returns:
assigned seat

getTravelerName

public String getTravelerName()
Returns the name of the traveler for this ticket.

Returns:
traveler name.

requestSeatChange

public boolean requestSeatChange(String seatDesignator)
                          throws IllegalArgumentException
Requests a seat change from the existing assignment to the designated seat. If the seat designator is ill-formed or already assigned to another passenger, the request is denied.

Parameters:
seatDesignator - String representation for desired seat (e.g., "28C")
Returns:
true if request accepted; false otherwise (e.g., if that seat is unavailable)
Throws:
IllegalArgumentException - if seatDesignator is invalid for the flight's seating configuration.