airline
Class Reservation

java.lang.Object
  extended by airline.Reservation
Direct Known Subclasses:
ProvisionalReservation

public class Reservation
extends Object

A Reservation manages an itinerary of one or more flights for a traveling party.

Author:
Michael Goldwasser

Method Summary
 void cancel()
          Cancels all tickets associated with this reservation.
 Iterator<Flight> getAllLegs()
          Returns an Iterator reporting all flights for this reservation.
 Iterator<String> getAllTravelerNames()
          Returns an Iterator reporting names of all travelers on this reservation.
 Customer getBooker()
          Returns the Customer who booked the reservation.
 Flight getLeg(int index)
          Returns the Flight with the given index.
 String getLocator()
          Return the record locator for this reservation.
 int getNumLegs()
          Returns the number of flight legs booked on this reservation.
 int getNumTravelers()
          Returns the number of travelers booked on this reservation.
 Flight.Ticket getTicket(int travIndex, int legIndex)
          Returns the ticket for the given traveler on the given leg of the reservation.
 String getTravelerName(int index)
          Returns the name of the traveler with given index.
 boolean isPurchased()
          Determines if the given reservation was formally purchased.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

cancel

public void cancel()
Cancels all tickets associated with this reservation.


getAllLegs

public Iterator<Flight> getAllLegs()
Returns an Iterator reporting all flights for this reservation.

Returns:
the Iterator of Flight instances.

getAllTravelerNames

public Iterator<String> getAllTravelerNames()
Returns an Iterator reporting names of all travelers on this reservation.

Returns:
the Iterator of traveler names.

getBooker

public Customer getBooker()
Returns the Customer who booked the reservation.

Returns:
the booker

getLeg

public Flight getLeg(int index)
Returns the Flight with the given index.

Parameters:
index - Legs of the reservation are zero-indexed
Returns:
the Flight

getLocator

public String getLocator()
Return the record locator for this reservation.

Returns:
String locator.

getNumLegs

public int getNumLegs()
Returns the number of flight legs booked on this reservation.

Returns:
number of flights.

getNumTravelers

public int getNumTravelers()
Returns the number of travelers booked on this reservation.

Returns:
number of travelers.

getTicket

public Flight.Ticket getTicket(int travIndex,
                               int legIndex)
                        throws IllegalStateException
Returns the ticket for the given traveler on the given leg of the reservation. Will return null if unticketed.

Parameters:
travIndex - Traveler names are zero-indexed starting with booking Customer.
legIndex - Flight legs are zero-indexed.
Returns:
The Flight.Ticket instance.
Throws:
IllegalStateException - if the reservation was never purchased.

getTravelerName

public String getTravelerName(int index)
Returns the name of the traveler with given index.

Parameters:
index - Travelers are zero-indexed
Returns:
the name of the traveler.

isPurchased

public boolean isPurchased()
Determines if the given reservation was formally purchased.

Returns:
true if purchased; false otherwise;