Project 1b: Create a Flights Database using ArrayList of Objects        For this Lab assignment, you will create an ArrayList of Java Objects,  populate them and print out the results.    Specifically, you will 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:  You should study the modules relating to ArrayLists,  ArrayList of Objects  SimpleDateFormat, and Java Enums. Create a new project in IntelliJ called for example FlightArrayList and a class FlightArrayList.  Follow the pattern in the ArrayLists of Objects module page.  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.   Flight and AircraftType should have public constructors to allow you to easily populate objects of these types.   Flight and AircraftType should have toString() (Links to an external site.) methods that display key Flight and AircraftType and EngineType attributes.   Create a main method that declares a variable of type ArrayList.  To make your life easier,  I suggest you create another ArrayList of type ArrrayList and populate it with various aircraft types since a Flight must have an AircraftType.   If you have an ArrayList of type ArrrayList pre-populated,  you can use the ArrayList get method to refer to an AircraftType,  e.g. acType.get(3) where acType is an ArrayList, referring to the fourth element in the AircraftType array list.  Set the engineType attributes using one of the EngineType enum values,  e.g. EngineType.Jet or EngineType.TurboProp.  Set up various aircraft types.   Here a few real examples, you can use to populate your AircraftType ArrayList.   AircraftType Examples:  Manufacturer Model Type Designator Engine Type Number Engines Boeing 737-600 B736 Jet 2 Boeing 737-800 B738 Jet 2 Airbus A-310 A310 Jet 2 Airbus A-300B2 A30B Jet 2 Airbus A-340-500 A-340-500 Jet 2 Embraer A-20 E314 TurboProp 1 Embraer 195 E195 Jet 2   8. You will also need to 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.  SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm"); // Now you can convert a dateString to a Java date like this:Date date = sdf.parse("12-10-2020 09:35") 9.  With aircraftTypes 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.  10.  Finally print out your results:  (requires you to define toString() methods in your Flight and AircraftType classes ) for (Flight flt: fltArrayList) { System.out.println(flt); } Sample Output: 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 UA 101 PHL/SFO Departs: 12-10-2020 08:35 Arrives: 12-10-2020 11:50 Aircraft: Airbus-A-310 EngType/Num: Jet/2 Gate: G15 DL 233 ATL/CDG Departs: 12-10-2020 16:35 Arrives: 12-11-2020 07:50 Aircraft: Airbus-A-310 EngType/Num: Jet/2 Gate: B15 WN 101 PHL/LAX Departs: 12-10-2020 08:35 Arrives: 12-10-2020 11:50 Aircraft: Airbus-A-340-500 EngType/Num: Jet/2 Gate: G15 AA 221 MCO/FLL Departs: 12-10-2020 05:35 Arrives: 12-10-2020 07:33 Aircraft: Airbus-A-310 EngType/Num: Jet/2 Gate: C11 UA 199 PHL/JFK Departs: 12-10-2020 08:35 Arrives: 12-10-2020 11:50 Aircraft: Embraer-A-20 EngType/Num: TurboProp/1 Gate: D15

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 9E
icon
Related questions
Question
100%

Project 1b: Create a Flights Database using ArrayList of Objects

      

For this Lab assignment, you will create an ArrayList of Java Objects,  populate them and print out the results.   

Specifically, you will create an ArrayList of type Flight (ArrayList<Flight>).   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. You should study the modules relating to ArrayLists,  ArrayList of Objects  SimpleDateFormat, and Java Enums.
  2. Create a new project in IntelliJ called for example FlightArrayList and a class FlightArrayList.  Follow the pattern in the ArrayLists of Objects module page. 
  3. 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. 
  4.  Flight and AircraftType should have public constructors to allow you to easily populate objects of these types.  
  5. Flight and AircraftType should have toString() (Links to an external site.) methods that display key Flight and AircraftType and EngineType attributes. 
  6.  Create a main method that declares a variable of type ArrayList<Flight>.
  7.  To make your life easier,  I suggest you create another ArrayList of type ArrrayList<AircraftType> and populate it with various aircraft types since a Flight must have an AircraftType.   If you have an ArrayList of type ArrrayList<AircraftType> pre-populated,  you can use the ArrayList get method to refer to an AircraftType,  e.g. acType.get(3) where acType is an ArrayList, referring to the fourth element in the AircraftType array list.  Set the engineType attributes using one of the EngineType enum values,  e.g. EngineType.Jet or EngineType.TurboProp.  Set up various aircraft types.   Here a few real examples, you can use to populate your AircraftType ArrayList.  

AircraftType Examples: 

Manufacturer Model Type Designator Engine Type Number Engines
Boeing 737-600 B736 Jet 2
Boeing 737-800 B738 Jet 2
Airbus A-310 A310 Jet 2
Airbus A-300B2 A30B Jet 2
Airbus A-340-500 A-340-500 Jet 2
Embraer A-20 E314 TurboProp 1
Embraer 195 E195 Jet 2

 

8. You will also need to 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. 

SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm");

// Now you can convert a dateString to a Java date like this:Date date = sdf.parse("12-10-2020 09:35")

9.  With aircraftTypes 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. 

10.  Finally print out your results:  (requires you to define toString() methods in your Flight and AircraftType classes )

for (Flight flt: fltArrayList) {
System.out.println(flt);
}

Sample Output: 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
UA 101 PHL/SFO Departs: 12-10-2020 08:35 Arrives: 12-10-2020 11:50 Aircraft: Airbus-A-310 EngType/Num: Jet/2 Gate: G15
DL 233 ATL/CDG Departs: 12-10-2020 16:35 Arrives: 12-11-2020 07:50 Aircraft: Airbus-A-310 EngType/Num: Jet/2 Gate: B15
WN 101 PHL/LAX Departs: 12-10-2020 08:35 Arrives: 12-10-2020 11:50 Aircraft: Airbus-A-340-500 EngType/Num: Jet/2 Gate: G15
AA 221 MCO/FLL Departs: 12-10-2020 05:35 Arrives: 12-10-2020 07:33 Aircraft: Airbus-A-310 EngType/Num: Jet/2 Gate: C11
UA 199 PHL/JFK Departs: 12-10-2020 08:35 Arrives: 12-10-2020 11:50 Aircraft: Embraer-A-20 EngType/Num: TurboProp/1 Gate: D15
 
Expert Solution
Step 1

Required a code: To provide a java code that can produce the below output. 

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
UA 101 PHL/SFO Departs: 12-10-2020 08:35 Arrives: 12-10-2020 11:50 Aircraft: Airbus-A-310 EngType/Num: Jet/2 Gate: G15
DL 233 ATL/CDG Departs: 12-10-2020 16:35 Arrives: 12-11-2020 07:50 Aircraft: Airbus-A-310 EngType/Num: Jet/2 Gate: B15
WN 101 PHL/LAX Departs: 12-10-2020 08:35 Arrives: 12-10-2020 11:50 Aircraft: Airbus-A-340-500 EngType/Num: Jet/2 Gate: G15
AA 221 MCO/FLL Departs: 12-10-2020 05:35 Arrives: 12-10-2020 07:33 Aircraft: Airbus-A-310 EngType/Num: Jet/2 Gate: C11
UA 199 PHL/JFK Departs: 12-10-2020 08:35 Arrives: 12-10-2020 11:50 Aircraft: Embraer-A-20 EngType/Num: TurboProp/1 Gate: D15

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
User Defined DataType
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,