Question: 1) Flight class has Attributes/ fields as -flightNum - source - destination - seats array(30 seats of type boolean (true-taken, false-available) ) 2) Booking class
1) Flight class has Attributes/ fields as -flightNum - source - destination - seats array(30 seats of type boolean (true-taken, false-available) )
2) Booking class have Methods as selectFlight selectSeat (as parametrized method given below)
a) selectFlight : source , destination : compare source destination and display flight numbers and the available seats b) selectSeat : enter FlightNum and seats -
book the ticket ( set the seat boolean to true for selected flight)
3.) Test Class have main method in main method create array of flights and you can book seat on particular flight and show at the end which seats are available and which are booked.
If users books seat 10 for the source: Amritsar and destination Detroit then the output should be Output should be 1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30
If again users books seat 10 for the source: Amritsar and destination Detroit then the output should be Your output should be
Seat is already booked
If users books seat 10 for the source: Detroit and destination Amritsar then the output should be Output should be 1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
