Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that uses the Airline class(described below) to assign seats for a commercial airplane. The airplane has 13 rows, with 6 seats

image text in transcribed  image text in transcribed 

Write a program that uses the Airline class(described below) to assign seats for a commercial airplane. The airplane has 13 rows, with 6 seats in each row - first row (1A, 1B, 1C, 1D, 1E, 1F) second row (2A. 2B, 2C, 2D, 2E, 2F)... Rows 1 and 2 are first class, rows 3 to 13 are economy class. Your program should create an object of the Airline class and display a menu with 5 choices: 1) Add a Reservation 2) Cancel a Reservation 3) Print Passenger Names and their Seats 4) Print the Seating Plan 5) Quit. The menu will be displayed as long as the choice is not Quit (5). If the choice is Add a Reservation, Cancel a Reservation, Print the Passenger Names and their Seats or Print the Seating Plan, the program will call the appropriate method in the class Airline. If the choice is Quit, the program will print the final Seating Plan and the list of passengers with their assigned seats. Print the last two in sorting order by name-remember these two are parallel arrays, so they must both be sorted! CLASS AIRLINE: Provide the following fields: the seating plan (a 13 by 6 array of char) the passengers' names (a string array of max 80) the passengers' seats (a string array of max 80) the lengths of the arrays (an integer) Provide the following methods: A constructor that initializes all fields A method to Add a reservation A method to Cancel a reservation A method to Print the passenger names and their seats A method to Print the seating plan A method to Print end of run information - called after Quit is selected Provide additional methods that will add modularity to your class - for example, a sorting method that can be called when you print the end of run information, methods that convert a seat string ("12C") into integer 12(row) and integer 3(column) for the seating plan array, etc. The method to Add a reservation should print the seating plan and ask the user to enter their name, the ticket type (first class or economy class) and the desired seat and should update the seating plan and the arrays that store the passengers' names and seats. Input validation: validate the desired seat. The method to Cancel a reservation should ask the user to enter their name, and if the passenger is in the list, should delete all the information related to the passenger and update the Seating Plan. If the name is not in the passenger list, the method should print an error message. The method to Print the passengers' names and seats should print all the passengers' names and their seats if there are any passenger, or "the plane is empty" if there are no passengers. The method to Print end-of-run information should print the final seating plan and the list of passengers with their assigned seats in sorting order by name. The method to print the Seating Plan should output the seating plan in the following format: 1) All asterisks () if plane is empty ABC DEF ROW 1 ROW 2 *** *** * *** ROW 3 * *** ROW 4 * *** ROW 5 * ROW 6 ROW 7 * ROW 8 ROW 9 ROW 10 * ROW 11 * ROW 12 ROW 13 * * 2) X instead of* for occupied seats (here seats 2A, 6F, 9B and 13F are occupied) ABC *** DEF *** ROW 1 ROW 2 ROW 3 X** *** ROW 4 * *** ROW 5 * ROW 6 * * * X ROW 7 * *** ROW 8 * *** ROW 9 * ROW 10 ROW 11 * ROW 12 * ROW 13 *

Step by Step Solution

3.52 Rating (155 Votes )

There are 3 Steps involved in it

Step: 1

Heres a Python implementation of the Airline class and the program class Airline def initself selfse... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java Concepts Late Objects

Authors: Cay S. Horstmann

3rd Edition

1119186714, 978-1119186717

More Books

Students also viewed these Programming questions

Question

How many applicants are you interviewing?

Answered: 1 week ago