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

📄 create.java

📁 This project developed in java leads us to realize a flight reservation system in order to emulate d
💻 JAVA
字号:
/* * Create.java * The package functions contains the different class executing the different functions of the FlightSystem Reservation. */package reservation.system.functions;import reservation.system.Flight;import java.util.HashSet;import java.util.Set;/** * This class hold Create structure. This object allows to create a new flight in the data base by calling the method <CODE>create</CODE> in {@link reservation.system.FlightSystem}. * @author Texier Mathieu and Frederic Bidon */public class Create extends Functions {       /**     * Create a new flight in a database if the command <CODE>create</CODE> and their arguments are correct.     * @throws Exception if the flight is not created.     * @return a confimation's message if the flight is created.     */    public String execute () throws Exception {        if (fs.create (arg[0], (short) Integer.parseInt (arg[1]), (short)Integer.parseInt (arg[2])))            return "Flight created \r\n";        else {throw new Exception ("The flight is not succesfully created");}    }    /**     * Verify invariants :     * <PRE>     * - Arguments not null     * - <CODE>rows</CODE> belongs to [1 <CODE>Flight.ROWS_MAX</CODE>]     * - <CODE>rowsLength</CODE> belongs to [1 <CODE>Flight.ROW_LENGTH_MAX</CODE>]     * </PRE>     * @throws Exception if the invariants is violated     */    void _check (String[] arg) throws Exception {    	try {        ArgumentIsValid (arg, 3, 3);        if (!checkInteger (arg[1], 1, Flight.ROWS_MAX))            throw new Exception ("The argument : rows has to be a number");        if (!checkInteger (arg[2], 1, Flight.ROW_LENGTH_MAX))            throw new Exception ("The argument : rows length has to be a number");         } catch (Exception e) {            throw new Exception (e.getMessage ()+ "\r\n" + usage ());        }    }       /**    * Display the usage for the command <CODE>create</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 the special \r\n";        usage += " character. \r\n";        usage += " - The argument <rows> is a number that belongs to [1 100].\r\n";        usage += " - The argument <rowLength> is a number that belongs to [1 10].\n";        return usage;    }}

⌨️ 快捷键说明

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