/*
* Flights.java
* The package functions contains the different class executing the different functions of the FlightSystem Reservation.
*/
package reservation.system.functions;
import reservation.system.FlightSystem;
/**
* 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}.
* @author Texier Mathieu and Frederic Bidon
*/
public class Flights extends Functions {
/**
* Display the list of the flights that are created if the command <CODE>flights</CODE> is correct.
* @throws Exception if the command is not executed.
* @return the names of the different flights created.
*/
String retString
= "Flight list :\r\n";
String[] flightList
= fs.
getFlightList ();
if (flightList.length == 0)
return "The flights' list is empty.\r\n";
for (int i=0; i< flightList.length; i++) {
retString += flightList[i] + " ";
}
return retString;
}
/**
* Verify that at least one flight is created.
* @throws Exception if it contains arguments or if no flight has been created.
*/
try {
CheckFlightListNotEmpty ();
ArgumentIsValid (arg, 0, 0);
throw new Exception (e.
getMessage ()+ "\r\n" + usage
());
}
}
/**
* Display the usage for the command <CODE>flights</code>.
* @return the usage.
*/
static public String usage
() {
String usage
= " Usage command flight: flight";
usage += " This command have to contain no argument.\n\r";
usage += "You must create at least one flight before to use this command.";
return usage;
}
}