Question: JAVA Create an Airline class that has the following properties: name flights (list of flights from airlines) Create a Flight class which has the following

JAVA

Create an Airline class that has the following properties: name flights (list of flights from airlines)

Create a Flight class which has the following properties: flightCode time capacity tickets (list of tickets registered for this flight)

Create a Passenger class which has the following properties: name age

Create an addFlight method on the Airline class that will create a new flight and add it to the flights property, then return the new flight. This method will also return the message: Flight ${flightCode} added to ${airlineName}

Release 1 Tickets will be divided into 3 classes: economy class business class first class

Create Ticket, Economy, Business, and First classes. And determine the form of inheritance of these classes. Those classes will have the following properties: booking Code passengers status price freeBaggage (amount of free baggage weight) extraBaggageFee (fee to be paid per kg for excess baggage from the amount of free weight.)

bookingCode will be generated with random letters of 6 characters with the following conditions: economy class tickets will start with the letter Y. For example: YKSTJD business class tickets will start with the letter J. For example: JKSTJD First class tickets will start with the letter F. For example: FKSTJD

status will have the initial value booked when the object is created. The status can later change to one of: paid, canceled, checked-in. price depends on the class of ticket: economy class ticket costs 200 business class ticket costs 300 first class ticket costs 400

freeBaggage depends on the class of the ticket: economy class ticket does not get free baggage business class tickets get 20 kg first class tickets get 45 kg

extraBaggageFee is the same for all classes i.e. 10. Create an issueTicket method in the Airline class. One of the inputs of this method is object flight. This method will create a new ticket and add it to the tickets property of the flight object and then return the new ticket. This method will also display the message: Booking code ${bookingCode} is issued for ${passengerName}. Please pay in 24 hours. Add validation that the flight entered is actually owned by the airline in question. Show message Invalid flight for ${airlineName} if the flight entered is invalid.

Release 2 Make a pay method in the Passenger class which will update the ticket status to paid. This method will also return the message ${PassengerName} paid the ticket with booking code ${bookingCode}. Create a checkIn method in the Passenger class which will update the ticket status from paid to checked-in. One of the inputs of this method is the weight of the baggage carried by the passenger. If the weight exceeds the free weight limit, the passenger must pay extra as much as the excess weight multiplied by extraBaggageFee. A successful check-in will change the ticket status to checked-in and display the message: if the passenger does not need to pay for the extra extra baggage, then the message ${passengerName} was checked in successfully. if passenger needs to pay for extra baggage, the message is ${passengerName} checked in successfully and paid ${extraFee} for extra baggage.. Also add validations: if the ticket status is still booked, it will display the message Oh sorry, ${passengerName} didn't pay the ticket yet. if the ticket status is canceled, it will display the message The ticket was canceled. if the ticket status is checked-in, it will display the message ${passengerName} already checked in before. If the person checking in is different from the passenger listed on the ticket, the message Only ${passengerName} can check in with this ticket will appear.

Especially for first class tickets, there will be a refund method. This method will change the ticket status to canceled and display the message ${refundAmount} has been transferred back to ${passengerName} bank account. Add validation that only tickets with paid status can be refunded. Tickets with other statuses will display the message This ticket can't get refund. Release 3 In the Flight class create the following getters: passengersInFlight (taken from the number of passengers who have checked in). emptySeats (number of empty seats calculated from flight capacity minus passengersInFlight)

Also create a depart method in the Flight class. This method will return message Flight ${flightCode} has departed with ${passengersInFlight} passengers, and ${emptySeats} empty seats

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!