|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectairline.Reservation
public class Reservation
A Reservation manages an itinerary of one or more flights
for a traveling party.
| Field Summary | |
|---|---|
private Customer |
booker
The customer who booked the reservation |
private ArrayList<Flight> |
legs
List of legs that are part of this itinerary |
private static Random |
rand
Used to generate record locators. |
private String |
recordLocator
A unique record locator identifying the reservation for the end user |
private Flight.Ticket[][] |
ticket
Two-dimensional array of tickets. |
private ArrayList<String> |
travelers
A list of names for one or more traveling companions (including the booker) |
| Constructor Summary | |
|---|---|
protected |
Reservation(Customer c)
Creates a new reservation for the given customer. |
| Method Summary | |
|---|---|
protected boolean |
addFlight(Flight f)
Attempts to add a flight as the next leg of the reservation. |
protected boolean |
addTraveler(String name)
Attempts to add a new traveler to the reservation. |
protected void |
allocateTicketArray()
Creates the underlying table based upon current number of travelers/legs. |
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. |
protected void |
setTicket(int travIndex,
int legIndex,
Flight.Ticket t)
Set entry of the underlying array of tickets. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private Customer booker
private ArrayList<Flight> legs
private static Random rand
private String recordLocator
private Flight.Ticket[][] ticket
private ArrayList<String> travelers
| Constructor Detail |
|---|
protected Reservation(Customer c)
ProvisionalReservation subclass
should be used.
The booking customer is automatically deemed the first traveler.
A six-letter record locator is randomly generated (it is presumed,
but not guaranteed, to be unique).
c - The booking Customer| Method Detail |
|---|
protected boolean addFlight(Flight f)
throws IllegalStateException
true if successful; false if this flight was already on the reservation.
f - the Flight instance
true if successful; false if duplicate flight
IllegalStateException - if the reservation has already been purchased.
protected boolean addTraveler(String name)
throws IllegalStateException
true if successful; false if this traveler was already on the reservation.
name - The name of the traveler
true if successful; false if duplicate
IllegalStateException - if the reservation has already been purchased.
protected void allocateTicketArray()
throws IllegalStateException
IllegalStateException - if already allocatedpublic void cancel()
public Iterator<Flight> getAllLegs()
Iterator reporting all flights for this reservation.
Iterator of Flight instances.public Iterator<String> getAllTravelerNames()
Iterator reporting names of all travelers on this reservation.
Iterator of traveler names.public Customer getBooker()
Customer who booked the reservation.
public Flight getLeg(int index)
Flight with the given index.
index - Legs of the reservation are zero-indexed
Flightpublic String getLocator()
String locator.public int getNumLegs()
public int getNumTravelers()
public Flight.Ticket getTicket(int travIndex,
int legIndex)
throws IllegalStateException
null if unticketed.
travIndex - Traveler names are zero-indexed starting with booking Customer.legIndex - Flight legs are zero-indexed.
Flight.Ticket instance.
IllegalStateException - if the reservation was never purchased.public String getTravelerName(int index)
index - Travelers are zero-indexed
public boolean isPurchased()
true if purchased; false otherwise;
protected void setTicket(int travIndex,
int legIndex,
Flight.Ticket t)
throws IllegalStateException
travIndex - traveler indexlegIndex - leg indext - The ticket reference
IllegalStateException - if array not allocated.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||