|
1 | 1 | package Client; |
2 | 2 |
|
3 | 3 | public enum Command { |
4 | | - Help("List all available commands", "[CommandName]"), |
| 4 | + Help("List all available commands", "[CommandName]"), |
5 | 5 |
|
6 | | - AddFlight("Add a new flight number", "<xid>,<FlightNumber>,<NumberOfSeats>,<PricePerSeat>"), |
7 | | - AddCars("Add a new car location", "<xid>,<Location>,<NumberOfCar>,<Price>"), |
8 | | - AddRooms("Add a new room location", "<xid>,<Location>,<NumberOfRoom>,<Price>"), |
9 | | - AddCustomer("Generate a new customer id", "<xid>"), |
10 | | - AddCustomerID("Create a new customer with the id", "<xid>,<CustomerID>"), |
| 6 | + AddFlight("Add a new flight number", "<xid>,<FlightNumber>,<NumberOfSeats>,<PricePerSeat>"), |
| 7 | + AddCars("Add a new car location", "<xid>,<Location>,<NumberOfCar>,<Price>"), |
| 8 | + AddRooms("Add a new room location", "<xid>,<Location>,<NumberOfRoom>,<Price>"), |
| 9 | + AddCustomer("Generate a new customer id", "<xid>"), |
| 10 | + AddCustomerID("Create a new customer with the id", "<xid>,<CustomerID>"), |
11 | 11 |
|
12 | | - DeleteFlight("Delete a flight number", "<xid>,<FlightNumber>"), |
13 | | - DeleteCars("Delete all cars at a location", "<xid>,<Location>"), |
14 | | - DeleteRooms("Delete all rooms at a location", "<xid>,<Location>"), |
15 | | - DeleteCustomer("Delete a customer (and return all reservations)", "<xid>,<CustomerID>"), |
| 12 | + DeleteFlight("Delete a flight number", "<xid>,<FlightNumber>"), |
| 13 | + DeleteCars("Delete all cars at a location", "<xid>,<Location>"), |
| 14 | + DeleteRooms("Delete all rooms at a location", "<xid>,<Location>"), |
| 15 | + DeleteCustomer("Delete a customer (and return all reservations)", "<xid>,<CustomerID>"), |
16 | 16 |
|
17 | | - QueryFlight("Query the number of available seats on a flight number", "<xid>,<FlightNumber>"), |
18 | | - QueryCars("Query the number of available cars at a location", "<xid>,<Location>"), |
19 | | - QueryRooms("Query the number of available rooms at a location", "<xid>,<Location>"), |
20 | | - QueryCustomer("Query a customer's bill", "<xid>,<CustomerID>"), |
| 17 | + QueryFlight("Query the number of available seats on a flight number", "<xid>,<FlightNumber>"), |
| 18 | + QueryCars("Query the number of available cars at a location", "<xid>,<Location>"), |
| 19 | + QueryRooms("Query the number of available rooms at a location", "<xid>,<Location>"), |
| 20 | + QueryCustomer("Query a customer's bill", "<xid>,<CustomerID>"), |
21 | 21 |
|
22 | | - QueryFlightPrice("Query the price per seat on a flight number", "<xid>,<FlightNumber>"), |
23 | | - QueryCarsPrice("Query the price per car at a location", "<xid>,<Location>"), |
24 | | - QueryRoomsPrice("Query the price per room at a location", "<xid>,<Location>"), |
| 22 | + QueryFlightPrice("Query the price per seat on a flight number", "<xid>,<FlightNumber>"), |
| 23 | + QueryCarsPrice("Query the price per car at a location", "<xid>,<Location>"), |
| 24 | + QueryRoomsPrice("Query the price per room at a location", "<xid>,<Location>"), |
25 | 25 |
|
26 | | - ReserveFlight("Reserve a flight number for a customer", "<xid>,<CustomerID>,<FlightNumber>"), |
27 | | - ReserveCar("Reserve a car for a customer at a location", "<xid>,<CustomerID>,<Location>"), |
28 | | - ReserveRoom("Reserve a room for a customer at a location", "<xid>,<CustomerID>,<Location>"), |
| 26 | + ReserveFlight("Reserve a flight number for a customer", "<xid>,<CustomerID>,<FlightNumber>"), |
| 27 | + ReserveCar("Reserve a car for a customer at a location", "<xid>,<CustomerID>,<Location>"), |
| 28 | + ReserveRoom("Reserve a room for a customer at a location", "<xid>,<CustomerID>,<Location>"), |
29 | 29 |
|
30 | | - Bundle("Book N flight numbers, and optionally a room and/or car at a location", "<xid>,<CustomerID>,<FlightNumber1>...<FlightNumberN>,<Location>,<Car-Y/N>,<Room-Y/N>"), |
| 30 | + Bundle("Book N flight numbers, and optionally a room and/or car at a location", "<xid>,<CustomerID>,<FlightNumber1>...<FlightNumberN>,<Location>,<Car-Y/N>,<Room-Y/N>"), |
31 | 31 |
|
32 | | - Quit("Exit the client application", ""); |
| 32 | + Quit("Exit the client application", ""); |
33 | 33 |
|
34 | | - String m_description; |
35 | | - String m_args; |
| 34 | + String m_description; |
| 35 | + String m_args; |
36 | 36 |
|
37 | | - Command(String p_description, String p_args) |
38 | | - { |
39 | | - m_description = p_description; |
40 | | - m_args = p_args; |
41 | | - } |
| 37 | + Command(String p_description, String p_args) { |
| 38 | + m_description = p_description; |
| 39 | + m_args = p_args; |
| 40 | + } |
42 | 41 |
|
43 | | - public static Command fromString(String string) |
44 | | - { |
45 | | - for (Command cmd : Command.values()) |
46 | | - { |
47 | | - if (cmd.name().equalsIgnoreCase(string)) |
48 | | - { |
49 | | - return cmd; |
50 | | - } |
51 | | - } |
52 | | - throw new IllegalArgumentException("Command " + string + " not found"); |
53 | | - } |
| 42 | + public static Command fromString(String string) { |
| 43 | + for (Command cmd : Command.values()) { |
| 44 | + if (cmd.name().equalsIgnoreCase(string)) { |
| 45 | + return cmd; |
| 46 | + } |
| 47 | + } |
| 48 | + throw new IllegalArgumentException("Command " + string + " not found"); |
| 49 | + } |
54 | 50 |
|
55 | | - public static String description() |
56 | | - { |
57 | | - String ret = "Commands supported by the client:\n"; |
58 | | - for (Command cmd : Command.values()) |
59 | | - { |
60 | | - ret += "\t" + cmd.name() + "\n"; |
61 | | - } |
62 | | - ret += "use help,<CommandName> for more detailed information"; |
63 | | - return ret; |
64 | | - } |
| 51 | + public static String description() { |
| 52 | + String ret = "Commands supported by the client:\n"; |
| 53 | + for (Command cmd : Command.values()) { |
| 54 | + ret += "\t" + cmd.name() + "\n"; |
| 55 | + } |
| 56 | + ret += "use help,<CommandName> for more detailed information"; |
| 57 | + return ret; |
| 58 | + } |
65 | 59 |
|
66 | | - public String toString() |
67 | | - { |
68 | | - String ret = name() + ": " + m_description + "\n"; |
69 | | - ret += "Usage: " + name() + "," + m_args; |
70 | | - return ret; |
71 | | - } |
| 60 | + public String toString() { |
| 61 | + String ret = name() + ": " + m_description + "\n"; |
| 62 | + ret += "Usage: " + name() + "," + m_args; |
| 63 | + return ret; |
| 64 | + } |
72 | 65 | } |
0 commit comments