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 of their seats
designated as first class and the remaining as coach class. For example, in a plane
with seats, there are first class seats at the front of the plane and coach class
seats after the end of the first class If there isnt an even split, the plane will have
slightly less than first class and slightly more than coach class. For example,
in a plane with seats, would be seats. In order to avoid going over the
maximum, this plane would have first class seats and 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
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 of
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 constructormethod should be documented using Javadoc comments. Make sure the
Javadoc explains the constructormethod to a person not familiar with the code.
The application class, Project 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.showInputDialogPlease 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 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 of
String choices Option "Option "Option "Option ;
int choice JOptionPane.showOptionDialog
null,
"Enter your choice...", text displayed in the window
"Main Menu", text displayed in the window's title bar
JOptionPane.DEFAULTOPTION,
JOptionPane.QUESTIONMESSAGE,
null,
choices, text to be displayed in each button
choices; default button
would display the following dialog box and choice would get a value of or depending
on the choice selected by the user. If a is returned, the user clicked the Option button. If a
is returned, the user clicked the Option 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 hisher 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 xtext displayed within the window
"Display Value", text displayed in the window's title bar
JOptionPane.INFORMATIONMESSAGE;
would display the following dialog box assuming that stored in the variable x
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
