booking system

  1. /*
  2.  * Flights.java
  3.  * The package functions contains the different class executing the different functions of the FlightSystem Reservation.
  4.  */
  5. package reservation.system.functions;
  6.  
  7. import reservation.system.FlightSystem;
  8.  
  9. /**
  10.  * This class hold Flights structure. This object allows to watch the list of the created flights by calling the command <CODE>flights</CODE> in {@link reservation.system.FlightSystem}.
  11.  * @author Texier Mathieu and Frederic Bidon
  12.  */
  13. public class Flights extends Functions {
  14.     /**
  15.      * Display the list of the flights that are created if the command <CODE>flights</CODE> is correct.
  16.      * @throws Exception if the command is not executed.
  17.      * @return the names of the different flights created.
  18.      */
  19.     public String execute () throws Exception {
  20.         String retString = "Flight list :\r\n";
  21.         String[] flightList = fs.getFlightList ();
  22.         if (flightList.length == 0)
  23.             return "The flights' list is empty.\r\n";
  24.        
  25.         for (int i=0; i< flightList.length; i++) {
  26.             retString += flightList[i] + " ";
  27.         }
  28.         return retString;
  29.     }
  30.  
  31.     /**
  32.      * Verify that at least one flight is created.
  33.      * @throws Exception if it contains arguments or if no flight has been created.
  34.      */
  35.     void _check (String[] arg) throws Exception {
  36.         try {
  37.         CheckFlightListNotEmpty ();
  38.         ArgumentIsValid (arg, 0, 0);
  39.          } catch (Exception e) {
  40.             throw new Exception (e.getMessage ()+ "\r\n" + usage ());
  41.         }
  42.     }
  43.    
  44.     /**
  45.     * Display the usage for the command <CODE>flights</code>.
  46.     * @return the usage.
  47.     */
  48.     static public String usage () {
  49.         String usage = " Usage command flight: flight";
  50.         usage += " This command have to contain no argument.\n\r";
  51.         usage += "You must create at least one flight before to use this command.";
  52.         return usage;
  53.     }
  54. }
  55.  

contact - link to this site