Question: 2. Write the class Flight which includes: a) 2 attributes: flight number and ArrayList of Passengers. b) one-arg constructor that accepts (as an argument) the

 2. Write the class Flight which includes: a) 2 attributes: flight

2. Write the class Flight which includes: a) 2 attributes: flight number and ArrayList of Passengers. b) one-arg constructor that accepts (as an argument) the flight number, and create a new empty ArrayList of Passengers. c) method addPassenger() that accepts a Passenger and add it to the ArrayList with a confirmation message. It is not allowed to add the same passenger twice and in this case an error message should be displayed. d) method oldestPassenger() which returns the name of oldest Passenger in the flight (whose age is the maximum). e) method savelntoFile() which accepts a file name. It stores the flight number and information of all Passengers in this file (each passenger in a different line)

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!