Question: Create a database tracking Flights information using an ArrayList of Java Objects, populate the list, and print out the results. Create an ArrayList of type

 Create a database tracking Flights information using an ArrayList of Java

Create a database tracking Flights information using an ArrayList of Java Objects, populate the list, and print out the results.

Create an ArrayList of type Flight (ArrayList). A Flight contains an attribute of type AircraftType, which is modeled above. An AircraftType contains an engineType attribute which is an enumeration type called EngineType.

Steps to create this project:

  1. Create the classes Flight and AircraftType and the EngineType enumeration as modeled above. For simplicity, these can be inner classes (Links to an external site.) of your public main class FlightArrayList.
  2. Flight and AircraftType should have public constructors to allow you to easily populate objects of these types.
  3. Flight and AircraftType should have toString() methods that display key Flight and AircraftType and EngineType attributes.
  4. Create a main method that declares a variable of type ArrayList.
  5. Set the scheduledArrival and scheduledDeparture times of flights. These schedules are of type Java Date. An easy way to do this to declare a SimpleDateFormat named, for example, sdf, then use the sdf to parse a date string into a Java Date (Example:
    Date date = sdf.parse("12-10-2020 09:35")
  6. With aircraft types and dates, you can now create Flights using the Flight constructor. Create five or more flights, varying data, times, aircraft types, destinations, origins, gates, and so on. Gates should start with a letter, followed by a number. Origin and destination should be three-letter airport codes, e.g. PHL, JFK, CDG, LAX, SFO, ORD, MIA, DFW, etc.
  7. Pint out your results: (requires to define toString() methods in Flight and AircraftType classes )
for (Flight flt: fltArrayList) { System.out.println(flt); } 

Example:

AA 101 PHL/ORD Departs: 12-10-2020 07:35 Arrives: 12-10-2020 09:35 Aircraft: Boeing-737-600 EngType/Num: Jet/2 Gate: A27

Aircraft Type Examples: Manufacturer (Boeing), Model (737-600), Type Designator (B736), Engine Type (Jet), Number Engines (2)

Flight Examples: FlightNumber (101 ), Airline (AA ), Origin (PHL), Destination (ORD), AircraftType (), scheduledDeparture (12-10-2020 07:35), scheduledArrival (12-10-2020 09:35), Gate (A27)

Thanks.

Flight -flightNumber -airline -origin -destination -aircraftType -scheduledDeparture -scheduledArrival -gate Aircraft Type -manufacturer -model -typeDesignator -engine Type engine Number Engine Type -Jet -Rocket -Electric -TurboProp -Piston

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!