reservation.system
Class FlightSystem

java.lang.Object
  extended byreservation.system.FlightSystem
All Implemented Interfaces:
java.io.Serializable

public final class FlightSystem
extends java.lang.Object
implements java.io.Serializable

The class hold the structure to access in the database. This object allows to modify the database with the different command available. It contains all the method executing all the command written by the user.

Author:
Frederic Bidon and Mathieu Texier
See Also:
Serialized Form

Method Summary
 boolean cancel(int bookingNumber)
          Method which allows to cancel a group of persons which have the same bookingNumber.
 boolean cancel(int bookingNumber, java.util.Set personNames)
          Method which allows to cancel one or more personName that have reserved.
 boolean create(Flight flight)
          Assert a new flight into the FlightList
 boolean create(java.lang.String flightName, short rows, short rowLength)
          Method which allows to add a new flight in a database.
 java.lang.Integer[] getBookingList()
          Method which allows to return the list of the atribuated bookingNumber.
 int getBookingNumberMax()
          Accessor for the bookingNumberMax
 java.lang.String[] getFlightList()
          Method which allows to return the flights contained in the flights' list.
static FlightSystem getInstance()
          Constructor of the class FlightSystem.
 java.util.Vector identify(int bookingNumber)
          Method which allows to see the personName which have the same bookingNumber.
 java.util.Vector list(java.lang.String flightName)
          Method which allows to see the personName present in a same flight.
 int reserve(Person person)
          Method which allows to add one person to a database.
 int reserve(java.lang.String flightName, java.util.Set personNames)
          Method which allows to add one or more persons in a database.
 java.util.Vector search(Profile profile)
          Method which allows to search a person in the person's list.
 Flight selectFlight(java.lang.String flightName)
          Method which allows to select a flight in the flight's list according to the flightName.
 java.lang.String toString()
          Returns a string representation of this FlightSystem object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static final FlightSystem getInstance()
Constructor of the class FlightSystem.

Returns:
the variable fs that is instantiated to FlightSystem object.

create

public final boolean create(java.lang.String flightName,
                            short rows,
                            short rowLength)
                     throws java.lang.Exception
Method which allows to add a new flight in a database.

Parameters:
flightName - The name of the flight
rows - the number of rows
rowLength - the length of each rows
Returns:
a boolean that confirm the creation of a new flight in the flight list.
Throws:
java.lang.Exception - if the flight already exists.

create

public final boolean create(Flight flight)
                     throws java.lang.Exception
Assert a new flight into the FlightList

Parameters:
flight - The Flight that will be asserted
Returns:
true if the flight exists.
Throws:
java.lang.Exception - if the flight doesn't exist.

reserve

public final int reserve(java.lang.String flightName,
                         java.util.Set personNames)
                  throws java.lang.Exception
Method which allows to add one or more persons in a database.

Parameters:
flightName - The name of the flight
personNames - A list of person
Returns:
the number of reservation(bookingNumber) for the group of person(s) registered.
Throws:
java.lang.Exception - if the flight doen't exist or if the command contains no personName.

reserve

public final int reserve(Person person)
                  throws java.lang.Exception
Method which allows to add one person to a database. The input is read from a file.

Parameters:
person - assert a Person Object
Returns:
1 if the person is added to a database or 0 if it is not added.
Throws:
java.lang.Exception - if the flight doen't exist or if the command contains no personName.

cancel

public final boolean cancel(int bookingNumber,
                            java.util.Set personNames)
                     throws java.lang.Exception
Method which allows to cancel one or more personName that have reserved.

Parameters:
bookingNumber - the booking number with which the person have booked
personNames - The name of the person that wnat to cancel
Returns:
true if the person(s) are canceled.
Throws:
java.lang.Exception - if one or more name are invalid.

cancel

public final boolean cancel(int bookingNumber)
                     throws java.lang.Exception
Method which allows to cancel a group of persons which have the same bookingNumber.

Parameters:
bookingNumber - The booking number to be canceled
Returns:
true if the group of person is canceled.
Throws:
java.lang.Exception - if the bookingNumber doesn't exist.

identify

public final java.util.Vector identify(int bookingNumber)
                                throws java.lang.Exception
Method which allows to see the personName which have the same bookingNumber.

Parameters:
bookingNumber - the booking number to be identify
Returns:
the personName who have the same bookingNumber.
Throws:
java.lang.Exception - if the bookingNumber doesn't exist.

list

public final java.util.Vector list(java.lang.String flightName)
                            throws java.lang.Exception
Method which allows to see the personName present in a same flight.

Parameters:
flightName - the name of the flight
Returns:
the personName present in a flight.
Throws:
java.lang.Exception - if the flightName doesn't exist.

toString

public final java.lang.String toString()
Returns a string representation of this FlightSystem object. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null

Returns:
a string representation of this FlightSystem object.

search

public final java.util.Vector search(Profile profile)
                              throws java.lang.Exception
Method which allows to search a person in the person's list.

Parameters:
profile - The person that will match this profile will be returned
Returns:
the list of persons found.
Throws:
java.lang.Exception - if the invariants is violated

selectFlight

public final Flight selectFlight(java.lang.String flightName)
                          throws java.lang.Exception
Method which allows to select a flight in the flight's list according to the flightName.

Parameters:
flightName - the name of the flight
Returns:
the flight selected if it exists.
Throws:
java.lang.Exception - if the flightName doesn't exist.

getBookingNumberMax

public final int getBookingNumberMax()
Accessor for the bookingNumberMax

Returns:
the number max of reservation on a flight.

getFlightList

public final java.lang.String[] getFlightList()
                                       throws java.lang.Exception
Method which allows to return the flights contained in the flights' list.

Returns:
the list of flight(s) created.
Throws:
java.lang.Exception - if the invariants are violated.

getBookingList

public final java.lang.Integer[] getBookingList()
                                         throws java.lang.Exception
Method which allows to return the list of the atribuated bookingNumber.

Returns:
the list of bookingNumber(s) present in the database.
Throws:
java.lang.Exception - if the invariants is violated.