lists.java

来自「This project developed in java leads us 」· Java 代码 · 共 64 行

JAVA
64
字号
/* * 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 + =
减小字号Ctrl + -
显示快捷键?