Système de réservation

  1. /*
  2.  * Lists.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.Person;
  8.  
  9. import java.util.Vector;
  10.  
  11. /**
  12.  * This class hold Lists structure. This object allows to see the person who are registered in one flight by calling the method <CODE>list</CODE> in {@link reservation.system.FlightSystem}.
  13.  * @author Texier Mathieu and Frederic Bidon
  14.  */
  15. public class Lists extends Functions {
  16.    
  17.     /**
  18.      * Display the list of the persons who are registered in one flight if the command <CODE>list</CODE> and their arguments are correct.
  19.      * @throws Exception the command is not executed.
  20.      * @return the names of the persons, their positions in the flight, and their bookingNumber.
  21.      */
  22.     public String execute() throws Exception {
  23.         String retString = "Flight list :\r\n";
  24.         Vector groupePersonVector = fs.list(arg[0]);
  25.         if (groupePersonVector.isEmpty())
  26.             return "The List is empty.\r\n";
  27.        
  28.         for (int i=0; i< groupePersonVector.size(); i++) {
  29.             Person person = (Person) groupePersonVector.get(i);
  30.             person._check();
  31.             retString += person;
  32.         }
  33.         return retString;
  34.     }
  35.    
  36.     /**
  37.      * Verify that at least one flight is created and also one reservation has been made.
  38.      * Verify invariants :
  39.      * <PRE>
  40.      * - Arguments not null
  41.      * </PRE>
  42.      * @throws Exception if the invariants is violated
  43.      */
  44.     void _check(String[] arg) throws Exception {
  45.         try {
  46.             CheckFlightListNotEmpty();
  47.             CheckBookingListNotEmpty();
  48.             ArgumentIsValid(arg, 1, 1);
  49.         } catch (Exception e) {
  50.             throw new Exception(e.getMessage()+ "\r\n" + usage());
  51.         }
  52.     }
  53.    
  54.     /**
  55.      * Display the usage for the command <CODE>list</code>.
  56.      * @return the usage.
  57.      */
  58.     static public String usage() {
  59.         String usage = " Usage command create: create <flightName> <rows> <rowLength>\n\r";
  60.         usage += " - The <flightName> can contain all the characters except \n\r";
  61.         usage +=" the syntax character.\n";
  62.         return usage;
  63.     }
  64. }

contact - faire un lien