Question: Create a class called Reservation according to the UML diagram to make a reservation on a flight. The seat preference will consist of a row

Create a class called Reservation according to the UML diagram to make a reservation on a flight. The seat preference will consist of a row number and seat letter (assume 21 rows and seats A, B, C and D).

Reservation

- seats: int [21][4]

- PassengerName: String

- ID : int

- flightNumber : String

- row: int

- seat: int (translate A to 0, B to 1, C to 2, D to 3)

+ Reservation (name : String , id : int, flight : String, requestedRow: int, requestedSeat: char)

+setRow(int : requestedRow) : void

+ setSeat(char : requestedSeat) : void

+ checkSeatAvailability (): boolean

+ makeReservation() : void

+ toString() : String

Attributes:

seatsa 2-dimensional array of "length" rows and "width" columns , assume that this is [21][4],

passengerName the name of the passenger

id : the id number of the passenger , assume that it cannot be zero

flightNumberthe name or flight number of the plane

rowthe passengers preference seat between 21 rows

seat - the passengers preference seat between 4 columns (A to D)

Methods:

Reservation - the constructor. It will allocate memory for the flight number, passengers name and id, and seating preferences of the passenger.

setRow it assigns its parameter value to the class field row

setSeat - it assigns its parameter value to the class field seat

checkSeatAvailability this method accepts the passengers seating preferences and returns false if the seat is already taken, otherwise returns true.

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!