📄 lists.java
字号:
/* * 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. */ public String execute() throws Exception { 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 */ void _check(String[] arg) throws Exception { try { CheckFlightListNotEmpty(); CheckBookingListNotEmpty(); ArgumentIsValid(arg, 1, 1); } catch (Exception e) { 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; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -