airline
Class AirlineSystem

java.lang.Object
  extended by airline.AirlineSystem
All Implemented Interfaces:
Serializable

public class AirlineSystem
extends Object
implements Serializable

The AirlineSystem manages the overall set of databases for users, flights, and reservations.

Author:
Michael Goldwasser
See Also:
Serialized Form

Nested Class Summary
private  class AirlineSystem.FlightDB
          A container of existing Flights
private  class AirlineSystem.UserDB
          A container of existing system Users.
 
Field Summary
private  AirlineSystem.FlightDB flights
          The set of flights for the airline system
private  AirlineSystem.UserDB users
          The set of registered users for the airline system
 
Constructor Summary
AirlineSystem()
          Create a new AirlineSystem.
 
Method Summary
 void addFlight(Flight f)
          Adds a Flight to the system.
 void addUser(User usr)
          Adds a User to the system.
 void ExportData(ObjectOutputStream oos)
          Serialize the entire AirlineSystem to an output stream.
 Iterator<Flight> getAllFlights()
          Returns an array of all flights currently in the system.
 Iterator<User> getAllUsers()
          Returns an array of all flights currently in the system.
 Flight getFlight(String flightCode)
          Returns the Flight with the given flight code (e.g., "UA200").
 User getUser(String ID)
          Returns the User associated with the given ID.
 void ImportData(ObjectInputStream ois)
          Load a previously exported version of the AirlineSystem.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flights

private AirlineSystem.FlightDB flights
The set of flights for the airline system


users

private AirlineSystem.UserDB users
The set of registered users for the airline system

Constructor Detail

AirlineSystem

public AirlineSystem()
Create a new AirlineSystem. System initially has a single administrative user with credentials: username="admin", password="secret"

Method Detail

addFlight

public void addFlight(Flight f)
               throws IllegalArgumentException
Adds a Flight to the system. The caller is responsible for ensuring that the new flight has been properly configured prior to entry into the system.

Parameters:
f - the new flight
Throws:
IllegalArgumentException - if system has existing flight with same flight number.

addUser

public void addUser(User usr)
             throws IllegalArgumentException
Adds a User to the system. The caller is responsible for ensuring that the new customer has been properly configured prior to entry into the system.

Parameters:
usr - the new User
Throws:
IllegalArgumentException - if system has existing customer with same ID.

ExportData

public void ExportData(ObjectOutputStream oos)
                throws IOException
Serialize the entire AirlineSystem to an output stream.

Parameters:
oos - An ObjectOutputStream such as a FileOutputStream.
Throws:
IOException

getAllFlights

public Iterator<Flight> getAllFlights()
Returns an array of all flights currently in the system.

Returns:
array of Flight instances

getAllUsers

public Iterator<User> getAllUsers()
Returns an array of all flights currently in the system.

Returns:
array of Flight instances

getFlight

public Flight getFlight(String flightCode)
Returns the Flight with the given flight code (e.g., "UA200"). If no such flight exists, returns null.

Parameters:
flightCode - a flight code (e.g., "UA200")
Returns:
Flight with given code, if it exists; otherwise null.

getUser

public User getUser(String ID)
Returns the User associated with the given ID. Returns null if the ID is not found.

Parameters:
ID - The customer ID
Returns:
reference to the User instance; null if ID not found.

ImportData

public void ImportData(ObjectInputStream ois)
                throws IOException,
                       ClassNotFoundException
Load a previously exported version of the AirlineSystem.

Parameters:
ois - An open ObjectInputStream such as a FileInputStream.
Throws:
IOException
ClassNotFoundException