Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A small airline would like to create a new automated reservations system. You have been asked to develop the new system. You are to write

A small airline would like to create a new automated reservations system. You have been asked to develop the new system. You are to write an application to assign seats on each flight of the airline's only plane (capacity: 15 seats).

Your application must: - Ask a user if they would like to select first class or economy - Assign the correct seat type with an appropriate number (1 5 for first class, 6 15 for economy) - Never assign a seat twice - Ask the user if they would like a different seat type, if their original type is already full. - Continue to ask the user if they would like to assign another seat until they select no.

Your bosses suggest that you structure the program as follows: A Seat class, which holds variables for the following information - Seat type (first class or economy) - Seat Number - Whether or not the seat is assigned - The constructor should take in 2 parameters, a seat type and a seat number. By default the assigned variable would be set to false - You will need mutator methods for the assigned variable - You will need accessor methods for all variables

A Plane class which holds an array of Seat objects. - The constructor for the plane class requires no parameters but would assign the Seat array to 15 Seat objects. o Seat numbers 1-15(not 0). 1 - 5 are in first class, 6 -15 are in economy. - There should be a method called getSeat that requires 1 parameter, the seat number. The method returns the entire Seat object with that seat number. - There should be a method called assignSeat. The method receives 1 parameter, a String (either first class or economy). The method searches for an empty seat with the given type and assigns the seat if possible. The method returns the seat number if the seat was assigned, the method returns -1 if it could not assign a seat.

An Application/Main class that interacts with a user and does the following: - Display the following alternatives: Please type (1) for First Class or Please type (2) for Economy. o If the user types 1, your application should assign a seat in the first-class section. Seats are assigned successively, not randomly. o If the user types 2, your application should assign a seat in the economy section. o Your application should then display a boarding pass indicating the person's seat number and whether it is in the first-class or economy section of the plane. - Your application should never assign a seat that has already been assigned. o When the economy section is full, your application should ask the person if it is acceptable to be placed in the first-class section (and vice versa). If yes, make the appropriate seat assignment. If no, display the message "Next flight leaves in 3 hours."

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books