|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object airline.Flight
public class Flight
Represents a single flight in the airline system. Each flight should have a unique code (e.g., "UA200"). Our model differs from reality in this respect, as we will not allow two different "UA200" entries (e.g., one from LAX to STL and another from STL to BOS).
Nested Class Summary | |
---|---|
class |
Flight.Ticket
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 . |
Constructor Summary | |
---|---|
Flight(String code,
String origin,
String destination,
int numRows,
String rowLayout)
Instantiates a new Flight instance. |
Method Summary | |
---|---|
Iterator<String> |
getAllAssignedSeats()
Returns an Iterator reporting the String designator (e.g., "28C")
for each assigned seat, in row-major order. |
Iterator<String> |
getAllEmptySeats()
Returns an Iterator reporting the String designator (e.g., "28C")
for each empty seat, in row-major order. |
String |
getDestination()
Return the airport code for the destination city. |
String |
getFlightCode()
Returns the (presumably unique) flight code (e.g., "UA200"). |
int |
getNumberEmptySeats()
Returns the current number of available seats on the flight. |
String |
getOrigin()
Return the airport code for the originating city. |
String |
getPassenger(String seat)
Returns the name of the passenger in the given seat. |
Flight.Ticket |
purchaseTicket(Reservation resv,
int travelerNumber)
Adds the specified traveler from the given Reservation to this flight. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Flight(String code, String origin, String destination, int numRows, String rowLayout) throws IllegalArgumentException
code
- A unique code for the flight (e.g., "UA200")origin
- Airport code for city of origin (e.g., "STL")destination
- Airport code for destination city (e.g., "STL")numRows
- Number of rows on this flightrowLayout
- Template for row configuration (e.g., "AC_DEFG_HJ")
IllegalArgumentException
- if rowLayout contains duplicate non-aisle characters.Method Detail |
---|
public Iterator<String> getAllAssignedSeats()
Iterator
reporting the String
designator (e.g., "28C")
for each assigned seat, in row-major order.
Iterator
public Iterator<String> getAllEmptySeats()
Iterator
reporting the String
designator (e.g., "28C")
for each empty seat, in row-major order.
Iterator
public String getDestination()
public String getFlightCode()
public int getNumberEmptySeats()
public String getOrigin()
public String getPassenger(String seat) throws IllegalArgumentException
null
.
seat
- The seat designation (e.g., "28C")
IllegalArgumentException
- if the seat designation is invalid.public Flight.Ticket purchaseTicket(Reservation resv, int travelerNumber)
Reservation
to this flight.
If the flight is already full, null
is returned.
Otherwise a Flight.Ticket
is returned with a valid seat assignment.
resv
- The Reservation
responsible for the original purchasetravelerNumber
- An index into the list of travelers on the given Reservation
Flight.Ticket
if space was available; otherwise null
.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |