/*
* Lists.java
* The package functions contains the different class executing the different functions of the FlightSystem Reservation.
*/
package reservation.system.functions;
import reservation.system.Person;
import java.util.Vector;
/**
* 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}.
* @author Texier Mathieu and Frederic Bidon
*/
public class Lists extends Functions {
/**
* Display the list of the persons who are registered in one flight if the command <CODE>list</CODE> and their arguments are correct.
* @throws Exception the command is not executed.
* @return the names of the persons, their positions in the flight, and their bookingNumber.
*/
String retString
= "Flight list :\r\n";
Vector groupePersonVector
= fs.
list(arg
[0]);
if (groupePersonVector.isEmpty())
return "The List is empty.\r\n";
for (int i=0; i< groupePersonVector.size(); i++) {
Person person = (Person) groupePersonVector.get(i);
person._check();
retString += person;
}
return retString;
}
/**
* Verify that at least one flight is created and also one reservation has been made.
* Verify invariants :
* <PRE>
* - Arguments not null
* </PRE>
* @throws Exception if the invariants is violated
*/
try {
CheckFlightListNotEmpty();
CheckBookingListNotEmpty();
ArgumentIsValid(arg, 1, 1);
throw new Exception(e.
getMessage()+ "\r\n" + usage
());
}
}
/**
* Display the usage for the command <CODE>list</code>.
* @return the usage.
*/
static public String usage
() {
String usage
= " Usage command create: create <flightName> <rows> <rowLength>\n\r";
usage += " - The <flightName> can contain all the characters except \n\r";
usage +=" the syntax character.\n";
return usage;
}
}