airline
Class AirlineSystem.UserDB

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

private class AirlineSystem.UserDB
extends Object
implements Serializable

A container of existing system Users.

Author:
Michael Goldwasser

Field Summary
private  HashMap<String,User> map
          We maintain underlying collection as a HashMap
 
Constructor Summary
AirlineSystem.UserDB()
          Creates an initially empty database.
 
Method Summary
 void add(User usr)
          Adds a User to the system.
 User getUser(String ID)
          Returns the User associated with the given ID.
 Iterator<User> iterator()
          Returns an iterator of User 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,User> map
We maintain underlying collection as a HashMap

Constructor Detail

AirlineSystem.UserDB

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

Method Detail

add

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

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.

iterator

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

Returns:
Iterator of User instances;