Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ASU CSE_205 Assignment8 The Following is a UML diagram, and partial codes in Ass

ID: 3802239 • Letter: A

Question

ASU CSE_205 Assignment8

The Following is a UML diagram, and partial codes in Assignment8.java,Flight.java,Schedule.java need to be filled.

Schedule

The Schedule class implements the "Serializable" interface so that its object can be stored. (The Serializable interface is defined in the "java.io" package.) It needs to define the following method:

public void copy(Schedule other)

It needs to copy every member variable value from "other" parameter to their corresponding variable of the object itself using "this" reference. For instance, if we have two objects of Schedule, schedule1 and schedule2, then, executing the following statement:

schedule1.copy(schedule2)

should resulting to have the object schedule1 to have the same city, year, month, date, and time value as the ones for schedule2, but schedule1 and schedule2 should not become aliases.

Flight

The Flight class implements the "Serializable" interface so that its object can be stored. (The Serializable interface is defined in the "java.io" package.) It needs to define the following method:

public void copy(Flight other)

It needs to copy every member variable value from "other" parameter to their corresponding variable of the object itself using "this" reference.

FlightNumberComparator

The FlightNumberComparator class implements the "Comparator" interface (The Comparator interface is in "java.util" package.). It needs to define the following method that was an inherited abstract method from Comparator interface:

public int compare(Object first, Object second)

(Note that you can also define:
public int compare(Flight first, Flight second)
instead by making the class implements Comparator<Flight>.

If the first argument object has a name of its airlines lexicographically less than that of the second argument, an int less than zero is returned. If the first argument object has a name of its airlines lexicographically larger than that of the second argument, an int greater than zero is returned. If their airlines names are same, then their flight numbers should be compared. If they have same airlines and flight numbers, then 0 should be returned.

DepartureComparator

The DepartureComparator class implements the "Comparator" interface (The Comparator interface is in "java.util" package.). It needs to define the following method that was an inherited abstract method from Comparator interface:

public int compare(Object first, Object second)

(Note that you can also define:
public int compare(Flight first, Flight second)
instead by making the class implements Comparator<Flight>.

If the first argument object has a city lexicographically less than that of the second argument, an int less than zero is returned. If the first argument object has a city lexicographically larger than that of the second argument, an int greater than zero is returned. If their cities are same, then their departure years should be compared. (if the first argument object has a smaller year, then it should return a negative integer. If the first argument object has a larger year, then it should return a positive integer.) If their cities and departure years are same, then their departure months should be compared. If their cities, departure years, and departure months are same, then their departure date should be compared. If their cities, departure years, departure months, and departure dates are same, then their departure time should be compared. If their cities, departure years, departure months, departure dates, and departure time are same, then 0 should be returned.

Sorts

The Sorts class is a utility class that will be used to sort a list of Flight objects. Sorting algorithms are described in the algorithm note posted under Notes section of the course web site. These algorithms sort numbers stored in an array. It is your job to modify it to sort an array of objects.
The Sorts class object will never be instantiated. It must have the following methods:

public static void sort(Flight[] flightList, int size, Comparator<Flight>)

Your sort method utilizes the compare method of the parameter Comparator object to sort. You can use one of Selection sort or Insertion Sort. The parameter size specifies how many first elements should be sorted. Note that not all elements in the array should be sorted, since some of them will be null pointers.

FlightManagement

The FlightManagement class has a list of Flight objects that can be organized at the flight management system. The flight management system will be a fully encapsulated object. The FlightManagement class implements the Serializable interface.
It has the following attributes:

The following public methods should be provided to interact with the flight management system:

No input/output should occur in the flight management system. User interaction should be handled only by the driver class.

You may add other methods to the class in order to make your life easier.

The Code part:

Assignment8.java

Flight.java

Schedule.java

Attribute name Attribute type Description flightList an array of Flight objects A list of Flight objects in the flight management system currentFlightsCount int the number of Flight objects created and stored in the flightList maxSize int the maximum number of Flight objects that can be stored in the flightList array. It is also the size of the flightList array. Schedule FlightNumberComparator Flight +compare(Object,Object) int Flight Management -flightList: Flight0 -currentFlightsCount:int maxSize nt +FlightManagement(int) +flightNumberExists (String,int):int +departureExists (String, int, nt, int, String) int taddFlight String. nt, String, String, int, String):boolean int tremove FlightNumber(String,int):boolean ttsortByFlightNumber(): void tsortByDeparture(): void +list Flights0: String +close FlightManagement():void Assignments CSE205 Arizona State University-Spring 2017 Departure Comparator +compare(Object,Object):int Assignment8 +main(Stringll): void +print Menu (0:void Sorts sort (Flight0, int, Comparator Flight :void

Explanation / Answer

Flight.java

Schedule.java