In this assignment, you will implement an airplane seat reservation system.
An airplane has two classes of service (first and economy). Each class has a sequence of seat rows. The following figure shows the seat chart
of the airplane.
In the above seat chart, the seat rows are numbered as 1,2, etc.
A reservation request has one of two forms. One form is that an individual passenger request consists of the passenger name, a class of service, and a seat preference such as W(indow), C(enter), or A(aisle) seats. The reservation program either finds a matching seat (the search may start from the first row of the class.) and reserves it for the passenger, or it fails if no matching seat is available. (For example, if the user's preference is a W(indow) seat and none is available, tell the user no Window seat is available and ask for another seat preference.) The other form is that a group request consists of a list of passenger names and a class of service. (Groups cannot specify a seat preference). The reservation program finds the first row of adjacent seats in a seat row that is sufficient to accommodate the group, or if no such seat row exists, finds the row with the largest number of adjacent seats in any seat row, fills it up with members of the group, and repeats that process (finding the row with the largest number of adjacent seats) until all members of the group have been seated. If there is insufficient space to seat all members of the group, none should be seated.
A cancellation request consists of the name of one or more passengers. The seats that are occupied by passengers in the request are emptied; passengers in the request that are not seated are ignored.
There are two kinds of report: seat availability chart and manifest list. A seat availability chart shows the available seats of each row of each class as shown below. You can guess the rest of the seat availability chart based on the example for the First Class.
Availability List:
First 1: B,D 2: C,D EconomyA manifest lists the occupied seats and the passengers seated in them:
First 1A: John Williams 1C: Harry Hacker 2A: Sarah Michaels 2B: Jonah Arks EconomyYour program must be called ReservationSystem. Start it with
java ReservationSystem flightnamewhere flightname is the name of a file that holds information from a prior program run. If the file does not exist, the program creates one.
The user interacts with the program to make a reservation, and the user input is read from standard input (System.in). The user interface for this program is as follows. Prompt the user:
Add [P]assenger, Add [G]roup, [C]ancel Reservations, Print Seating [A]vailability Chart, Print [M]anifest, [Q]uit
The following describes the function(s) of each option.
Name: John Smith Service Class: First Seat Preference: WPrint the seat number such as 1A on which the passenger has been seated, or Request failed.
Group Name: cssjsu Names: Venkathan Subramanian,Karl Schulz Service Class: EconomyPrint the seat numbers on which the passengers have been seated, or Request failed.
Names: John SmithWhen the user wants to cancel a group reservation, prompt as follows: (bold are user inputs)
Group Name: cssjsuA cancellation of a group reservation will cancel the reservations of all group members. For simplicity, let's assume an individual group member cannot cancel his/her reservation only.
java ReservationSystem CL34the file doesn't exist, and thus the program creates one. Then, suppose reservations X, Y, Z are made, and the program quits. Then, X, Y, Z are stored in the file CL34. In the second time of program execution, the ReservationSystem restores reservations (X, Y, Z) from CL34. Suppose Y is cancelled, and A and B are added. The file contains X, Z, A, and B only.
java ReservationSystem CL34 < input.txtassuming that the file CL34 doesn't exist when the program executes for the first time.