⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reserve.java

📁 This project developed in java leads us to realize a flight reservation system in order to emulate d
💻 JAVA
字号:
/* * Reserve.java * The package functions contains the different class executing the different functions of the FlightSystem Reservation. */package reservation.system.functions;import java.util.HashSet;import java.util.Set;/** * This class hold Reserve structure. This object allows to reserve to one flight one or many persons by calling the method <CODE>reserve</CODE> in {@link reservation.system.FlightSystem}. * @author Texier Mathieu and Frederic Bidon */public class Reserve extends Functions {        /**     * Reserve several one or many person in one flight if the command <CODE>reservation</CODE> and their arguments are correct.     * @throws Exception if a person name is duplicated or if the person are not registered.     * @return a confimation's message if the person(s) are registered.     */    public String execute() throws Exception {        Set setPersonNames = new HashSet();        for (int i = 1; i< arg.length; i++)            setPersonNames.add(arg[i]);                if(setPersonNames.size() != arg.length -1)            throw new Exception("no duplicate name are allowed in reserve comande");                int BookingNumber = fs.reserve(arg[0], setPersonNames);        if (BookingNumber != -1){            return "Your booking number is " + BookingNumber +".\r\n" +            "\tPlease, don't forget this booking number.\r\n" +            " It could be usefull to cancel your reservation.\r\n";        } else {throw new Exception("The person are not succesfully reserved");}    }        /**     * Verify that at least one flight is created.     * Verify invariants :     * <PRE>     * - Arguments not null     * </PRE>     * @throws Exception if the invariants is violated     */        void _check(String[] arg) throws Exception {        try {            CheckFlightListNotEmpty();            ArgumentIsValid(arg, 2, (short) NUMBER_ARGUMENT_MAX);        } catch (Exception e) {            throw new Exception(e.getMessage()+ "\r\n" + usage());        }    }        /**     * Display the usage for the command <CODE>reserve</code>.     * @return the usage.     */    static public String usage() {        String usage = " Usage command reserve: reserve <flightName> <personName1> [personName2] [...]\n\r";        usage += " - The <flightName> can contain all the characters except the syntax character.\r\n";        usage += " - The arguments <personNameX> which follow correspond to the name of the \n\r";        usage += " different persons that you want to register on the flight.\r\n";        usage += "\t The first letter of each passenger must be in  uppercase and all \n\r";        usage += "\t the other in lowercase.\n\r";        usage += "\t The number of name cannot be superior to the free place of the plane.\n";        return usage;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -