airline
Class AirlineSystem.FlightDB

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

private class AirlineSystem.FlightDB
extends Object
implements Serializable

A container of existing Flights

Author:
Michael Goldwasser

Field Summary
private  HashMap<String,Flight> map
          We maintain underlying collection as a HashMap
 
Constructor Summary
AirlineSystem.FlightDB()
          Creates an initially empty database.
 
Method Summary
 void add(Flight f)
          Adds a Flight to the system.
 Flight getFlight(String code)
          Returns the Flight associated with the given code.
 Iterator<Flight> iterator()
          Returns an iterator of Flight instances.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

private HashMap<String,Flight> map
We maintain underlying collection as a HashMap

Constructor Detail

AirlineSystem.FlightDB

public AirlineSystem.FlightDB()
Creates an initially empty database.

Method Detail

add

public void add(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.

getFlight

public Flight getFlight(String code)
Returns the Flight associated with the given code. Returns null if the code is not found.

Parameters:
code - The flight code (e.g., "UA200")
Returns:
reference to the Flight instance; null if code not found.

iterator

public Iterator<Flight> iterator()
Returns an iterator of Flight instances.

Returns:
Iterator of Flight instances;