Question: Airplane Class: An instance of the Airplane class should store a reference to a Seat array which stores references to the seats on the plane,

Airplane Class:
An instance of the Airplane class should store a reference to a Seat array which stores references
to the seats on the plane, the number of seats in first class, and the number of seats in coach. The
Airplane class should provide the following behaviors:
A parameterized constructor that creates the array based upon the number of seats
passed to it as well as the actual seats. All planes have a maximum of 40% of their seats
designated as first class and the remaining 60% as coach class. For example, in a plane
with 10 seats, there are 4 first class seats (at the front of the plane) and 6 coach class
seats (after the end of the first class). If there isnt an even split, the plane will have
slightly less than 40% first class and slightly more than 60% coach class. For example,
in a plane with 14 seats, 40% would be 5.6 seats. In order to avoid going over the 40%
maximum, this plane would have 5 first class seats and 9 coach class seats.
A method to determine and return the number of occupied seats for a particular class
(first or coach).
A method to assign a first class or coach class seat. Each row in the plane only has 1
seat. The user should be asked whether they want a first class or coach seat and then
presented with a list of available seats. The seat should be assigned only if it is
currently available.
Page 5 of 7
A method to cancel a specific previously reserved first class or coach class seat. The
user should be prompted for a seat number. The seat should be canceled only if it is
currently occupied.
A toString method which returns a string containing the state of the Airplane.
Each constructor/method should be documented using Javadoc comments. Make sure the
Javadoc explains the constructor/method to a person not familiar with the code.
The application class, Project1, must thoroughly tests the Seat and Airplane classes to make sure
that planes of different sizes can be created, they have the proper ratio of first class to coach class
seats, available seats can be reserved, reservations can be canceled (but only if occupied), etc.
Include comments that explain how you tested the Seat and Airplane classes.
Testing this will require you to sit down with the output and really look at it putting in
meaningful labels will be important and tracing through your code may be helpful.
Comment out the code you wrote to test the Seat, and Airplane classes. Do not modify this code
as you need to submit it for grading.
The Application Class
The application class should interact with the user using dialog boxes. The JOptionPane class
provides a number of methods that will create dialog boxes for you. To use the JOptionPane
class you will have to import javax.swing.JOptionPane;
JOptionPanes showInputDialog method is used to prompt the user to enter input. The method
returns the user input as a String. For example,
String airlineCarrier = JOptionPane.showInputDialog(Please enter the airline carrier);
would display the following dialog box. The characters entered in the textbox would be returned
as a String.
The application class should ask the user for the number of seats the plane has so it can create an
Airplane object with the proper number of seats.
The user will interact with a menu that has 4 options: Make a Reservation, Cancel a
Reservation, Display a Seating Chart and Quit. Use the showOptionDialog method to display
the menu and get the users choice. For example,
Page 6 of 7
String[] choices ={"Option 1", "Option 2", "Option 3", "Option 4"};
int choice = JOptionPane.showOptionDialog(
null,
"Enter your choice...", //text displayed in the window
"Main Menu", //text displayed in the window's title bar
JOptionPane.DEFAULT_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
choices, //text to be displayed in each button
choices[0]); //default button
would display the following dialog box and choice would get a value of 0,1,2, or 3 depending
on the choice selected by the user. If a 0 is returned, the user clicked the Option 1 button. If a 1
is returned, the user clicked the Option 2 button, etc...
The application should process the users choice. In some situations, additional input will be
required from the user. The user should be provided with detailed feedback regarding the
processing of his/her request. The main menu should continue to appear until such time that the
user selects quit.
The showMessageDialog method is used to display output in a dialog box. For example,
JOptionPane.showMessageDialog(
null,
"The value of x is "+ x,//text displayed within the window
"Display Value", //text displayed in the window's title bar
JOptionPane.INFORMATION_MESSAGE);
would display the following dialog box assuming that 10 stored in the variable x

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!