Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Reference class (35 points) Write a reference class called Flight that models information about an airline flight. The instance variables should contain information about the

Reference class (35 points)

Write a reference class called Flight that models information about an airline flight. The instance variables should contain information about the flight's:

airline name, a string;

flight number, an integer;

origin, a string with a three-letter airport code (e.g., MDW, ORD, JFK);

destination, also a three-letter airport code;

departure time, as a string of the form "hh:mm";

arrival time, as a string of the form "hh:mm".

The API will consist of:

a six-parameter constructor, passing in the six pieces of information listed above;

six accessor methods for retrieving the value of each instance variable. For example, the signature of the first one will be public String airline()

a toString() method that produces a string looking like this: [Southwest, 678, MDW, MCI, 13:34, 15:03], where the values are in the order listed above;

a compareTo(Flight that) method that compares Flight objects based on the concatenation of the airline and the flight number. For example, Southwest flight number 678 should be sorted by the string "Southwest678".

Next write a program ListFlights.java that reads the flight data from an input file, places it into either an array or an array list, and then prints three tables: one with the data sorted by airline-flight number (the natural order, one with the data sorted by the departure airport, and one by the arrival airport. Use either the method Arrays.sort(T[] a, Comparator c) or the method Collections.sort(List list, Comparator c).

If you wish, you may sort one of the last two tables using a lambda-method but, no matter what, you must write both Comparators.

Input File: United 672 ORD DEN 07:05 10:10 
United 692 ORD DEN 17:20 20:45 
United 682 ORD DEN 09:10 10:10 
United 571 ORD CAE 06:40 08:50 
United 7123 ORD CAE 15:20 17:30 
Southwest 123 MDW SLC 21:05 23:50 
Southwest 127 MDW SLC 10:20 12:55 
Southwest 124 SLC MDW 17:35 19:55 
Southwest 128 SLC MDW 11:25 14:00 
American 770 ORD DEN 11:00 14:40 
American 890 ORD DEN 15:10 18:50 
American 775 DEN ORD 09:15 12:45 
American 673 DEN ORD 12:10 15:40 
Southwest 1245 MDW BWI 09:40 11:50 
Southwest 1001 MDW BWI 13:20 15:30 
Southwest 890 BWI MDW 15:55 18:00 
Southwest 780 BWI MDW 10:35 12:40 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

4. Does cultural aptitude impact ones emotional intelligence?

Answered: 1 week ago

Question

Q.No.1 Explain Large scale map ? Q.No.2 Explain small scale map ?

Answered: 1 week ago

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago