Question: Please give the exact code to match the exact outputs in java thanks and provide all the neccessary java files. Please give all the java
Please give the exact code to match the exact outputs in java thanks and provide all the neccessary java files. Please give all the java files to produce the correct output thank you. The output should match to the one given below so the test cases pass thanks..
Assignment8 file -
// Assignment #: 8 // Name: // StudentID: // Lecture: // Description: The Assignment 8 class displays a menu of choices to a user // and performs the chosen task. It will keep asking a user to // enter the next choice until the choice of 'Q' (Quit) is // entered. import java.io.*; public class Assignment8 { public static void main (String[] args) { char input1; String airlines, depCity, depTime, arrCity, arrTime; String flightNumStr, depYearStr, depMonthStr, depDateStr, arrYearStr, arrMonthStr, arrDateStr;; int flightNum, depYear, depMonth, depDate, arrYear, arrMonth, arrDate; boolean operation = false; int operation2 = 0; String line; String filename; // create a FlightManagement object. This is used throughout this class. FlightManagement manage1 = null; try { // print out the menu printMenu(); // create a BufferedReader object to read input from a keyboard InputStreamReader isr = new InputStreamReader (System.in); BufferedReader stdin = new BufferedReader (isr); System.out.print("Please enter a maximum number of flights "); String maxStr = stdin.readLine().trim(); //read in the max number as a string int max = Integer.parseInt(maxStr); manage1 = new FlightManagement(max); do { System.out.print("What action would you like to perform? "); line = stdin.readLine().trim(); //read a line input1 = line.charAt(0); input1 = Character.toUpperCase(input1); if (line.length() == 1) //check if a user entered only one character { switch (input1) { case 'A': //Add Flight System.out.print("Please enter a flight to add: "); System.out.print("Please enter its airlines to add: "); airlines = stdin.readLine().trim(); System.out.print("Please enter its flight number to add: "); flightNumStr = stdin.readLine().trim(); flightNum = Integer.parseInt(flightNumStr); System.out.print("Please enter its departure city to add: "); depCity = stdin.readLine().trim(); System.out.print("Please enter its departure year to add: "); depYearStr = stdin.readLine().trim(); depYear = Integer.parseInt(depYearStr); System.out.print("Please enter its departure month to add: "); depMonthStr = stdin.readLine().trim(); depMonth = Integer.parseInt(depMonthStr); System.out.print("Please enter its departure date to add: "); depDateStr = stdin.readLine().trim(); depDate = Integer.parseInt(depDateStr); System.out.print("Please enter its departure time to add: "); depTime = stdin.readLine().trim(); System.out.print("Please enter its arrival city to add: "); arrCity = stdin.readLine().trim(); System.out.print("Please enter its arrival year to add: "); arrYearStr = stdin.readLine().trim(); arrYear = Integer.parseInt(arrYearStr); System.out.print("Please enter its arrival month to add: "); arrMonthStr = stdin.readLine().trim(); arrMonth = Integer.parseInt(arrMonthStr); System.out.print("Please enter its arrival date to add: "); arrDateStr = stdin.readLine().trim(); arrDate = Integer.parseInt(arrDateStr); System.out.print("Please enter its arrival time to add: "); arrTime = stdin.readLine().trim(); operation = manage1.addFlight(airlines, flightNum, depCity, depYear, depMonth, depDate, depTime, arrCity, arrYear, arrMonth, arrDate, arrTime); if (operation == true) System.out.print("flight added "); else System.out.print("flight not added "); break; case 'C': //Create a new flight management System.out.print("Please enter a new maximum number of flights: "); maxStr = stdin.readLine().trim(); //read in the max number as a string max = Integer.parseInt(maxStr); manage1 = new FlightManagement(max); break; case 'D': //Search by flight number System.out.print("Please enter Airlines to search: "); airlines = stdin.readLine().trim(); System.out.print("Please enter flight number to search: "); flightNumStr = stdin.readLine().trim(); flightNum = Integer.parseInt(flightNumStr); operation2=manage1.flightNumberExists(airlines, flightNum); if (operation2 > -1) System.out.print("flight number " + airlines + flightNum + " found "); else System.out.print("flight number " + airlines + flightNum + " not found "); break; case 'E': //Search by departure System.out.print("Please enter departure city to search: "); depCity = stdin.readLine().trim(); System.out.print("Please enter its departure year to search: "); depYearStr = stdin.readLine().trim(); depYear = Integer.parseInt(depYearStr); System.out.print("Please enter its departure month to search: "); depMonthStr = stdin.readLine().trim(); depMonth = Integer.parseInt(depMonthStr); System.out.print("Please enter its departure date to search: "); depDateStr = stdin.readLine().trim(); depDate = Integer.parseInt(depDateStr); System.out.print("Please enter its departure time to search: "); depTime = stdin.readLine().trim(); operation2=manage1.departureExists(depCity, depYear, depMonth, depDate, depTime); if (operation2 > -1) { System.out.print("flight departure " + depCity + "," + depMonth + "-" + depDate + "-" + depYear +"," + depTime + " found "); } else { System.out.print("flight departure " + depCity + "," + depMonth + "-" + depDate + "-" + depYear +"," + depTime + " not found "); } break; case 'L': //List flights System.out.print(manage1.listFlights()); break; case 'O': // Sort by flight numbers manage1.sortByFlightNumber(); System.out.print("sorted by flight numbers "); break; case 'P': // Sort by departure information manage1.sortByDeparture(); System.out.print("sorted by departures "); break; case 'Q': //Quit break; case 'R': //Remove by flight number System.out.print("Please enter Airlines to remove: "); airlines = stdin.readLine().trim(); System.out.print("Please enter flight number to remove: "); flightNumStr = stdin.readLine().trim(); flightNum = Integer.parseInt(flightNumStr); operation=manage1.removeFlightNumber(airlines, flightNum); if (operation == true) System.out.print("flight number " + airlines + flightNum + " removed "); else System.out.print("flight number " + airlines + flightNum + " not found "); break; case 'T': //Close FlightManagement manage1.closeFlightManagement(); System.out.print("flight management system closed "); break; case 'U': //Write Text to a File System.out.print("Please enter a file name to write: "); filename = stdin.readLine().trim(); /************************************************************************************ *** ADD your code to write a text (string) to the specified file. Catch exceptions. ************************************************************************************/ break; case 'V': //Read Text from a File System.out.print("Please enter a file name to read: "); filename = stdin.readLine().trim(); /************************************************************************************ *** ADD your code to read a text (string) from the specified file. Catch exceptions. ************************************************************************************/ break; case 'W': //Serialize FlightManagement to a File System.out.print("Please enter a file name to write: "); filename = stdin.readLine().trim(); /************************************************************************************ *** ADD your code to write the flight management bject to the specified file. Catch exceptions. ************************************************************************************/ break; case 'X': //Deserialize FlightManagement from a File System.out.print("Please enter a file name to read: "); filename = stdin.readLine().trim(); /************************************************************************************ *** ADD your code to read a flight management object from the specified file. Catch exception. ***********************************************************************************/ break; case '?': //Display Menu printMenu(); break; default: System.out.print("Unknown action "); break; } } else { System.out.print("Unknown action "); } } while (input1 != 'Q' || line.length() != 1); } catch (IOException exception) { System.out.print("IO Exception "); } } /** The method printMenu displays the menu to a user **/ public static void printMenu() { System.out.print("Choice\t\tAction " + "------\t\t------ " + "A\t\tAdd Flight " + "C\t\tCreate FlightManagement " + "D\t\tSearch by Flight Number " + "E\t\tSearch by Departure " + "L\t\tList Flights " + "O\t\tSort by Flight Number " + "P\t\tSort by Departure " + "Q\t\tQuit " + "R\t\tRemove by Flight Number " + "T\t\tClose FlightManagement " + "U\t\tWrite Text to File " + "V\t\tRead Text from File " + "W\t\tSerialize FlightManagement to File " + "X\t\tDeserialize FlightManagement from File " + "?\t\tDisplay Help "); } } // end of Assignment8 class // Assignment #: // Name: // StudentID: // Lecture: // Description: The Flight class describes attributes in a flight // and provides accessor and mutator methods for each // instance variables as well as toString method. public class Flight { private String airlines; private int flightNum; private Schedule departure; private Schedule arrival; //Constructor method to initialize each variable. public Flight() { airlines = new String("?"); flightNum = 0; departure = new Schedule(); arrival = new Schedule(); } //Accessor methods public String getAirlines() { return airlines; } public int getFlightNum() { return flightNum; } public Schedule getDeparture() { return departure; } public Schedule getArrival() { return arrival; } //Mutator methods public void setAirlines(String airlinesName ) { airlines = airlinesName; } public void setFlightNum(int fNumber) { flightNum = fNumber; } public void setDeparture(String someCity, int someYear, int someMonth, int someDate, String someTime) { departure.setCity(someCity); departure.setYear(someYear); departure.setMonth(someMonth); departure.setDate(someDate); departure.setTime(someTime); } public void setArrival(String someCity, int someYear, int someMonth, int someDate, String someTime) { arrival.setCity(someCity); arrival.setYear(someYear); arrival.setMonth(someMonth); arrival.setDate(someDate); arrival.setTime(someTime); } /************************************* Define a copy method that copies every member variable value from "other" parameter to their corresponding variable of the object itself using "this" reference **************************************/ public void copy(Flight other) { //To be defined } //This method returns a String containing attribute(variable) values //of a flight. public String toString() { String result = " Airlines:\t" + airlines + " " + "Number:\t\t" + flightNum + " " + "Departure:\t" + departure.toString() + " " + "Arrival:\t" + arrival.toString() + " "; result += " "; return result; } } // Assignment #: // Name: // StudentID: // Lecture: // Description: The Schedule class descrives a departure or an arrival // information of a flight including a city, time, and date. // It also provides their accessor, mutator methods, // and toString method. public class Schedule { private String city; private int year; private int month; private int date; private String time; //Constructor method to initialize intance variables. public Schedule() { city = new String("?"); time= new String("?"); year = 0; month = 0; date = 0; } //Accessor methods public String getCity() { return city; } public String getTime() { return time; } public int getYear() { return year; } public int getMonth() { return month; } public int getDate() { return date; } //Modifier methods public void setCity(String place) { city = place; } public void setTime(String someTime) { time = someTime; } public void setDate(int someDate) { date = someDate; } public void setYear(int someYear) { year = someYear; } public void setMonth(int someMonth) { month = someMonth; } /************************************* Define a copy method that copies every member variable value from "other" parameter to their corresponding variable of the object itself using "this" reference **************************************/ public void copy(Schedule other) { //To be defined } //This method return a string containing the attribute information in //departure or arrival. public String toString() { String result; result = city + "," + month + "-" + date + "-" + year + "," + time; return result; } } You are required, but not limited, to turn in the following source files:
Assignment8.java(More code need to be added) Flight.java(given by the instructor, it needs to be modified for this assignment) Schedule.java(given by the instructor, it needs to be modified for this assignment) FlightNumberComparator.java DepartureComparator.java Sorts.java FlightManagement.java
Requirements to get full credits in Documentation
The assignment number, your name, StudentID, Lecture number/time, and a class description need to be included at the top of each file/class.
A description of each method is also needed.
Some additional comments inside of methods(especially for the "main" method) to explain code that are hard to follow should be written.
You can look at the Java programs in the text book to see how comments are added to programs.
Skills to be Applied
In addition to what has been covered in previous assignments, the use of the following items, discussed in class, will probably be needed:
Sorting Searching Aggregate Objects Interfaces Serialization File read/write
Program Description
Class Diagram:
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
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
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
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:
| 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. |
The following public methods should be provided to interact with the flight management system:
| Method | Description |
|---|---|
| FlightManagement(int maximumsize) | A Constructor of the FlightManagement class. Using the parameter value, it should initialize the member variable maxSize. Then it should instantiate an array of Flight objects using the maxSize, and initialize each slot of the array to null for every index. It should also initialize the member variable currentFlightsCount to 0. |
| int flightNumberExists(String airlines, int flightNumber) | Search for a Flight object by airlines and flightNumber, and return the index of the object if found. Return -1 if not found. The parameters are airlines and flightNum of a Flight object. |
| int departureExists(String city, int year, int month, int date, String time) | Search and for Flight objects in the flight list that have the same departure city, year, month, date, and time as the parameter values and return the index of such object if found. Return -1 if not found. |
| boolean addFlight(String airlines, int flightNum, String depCity, int depYear, int depMonth, int depDate, String depTime, String arrCity,int arrYear, int arrMonth, int arrDate, String arrTime) | Add a Flight object to the flight list and return true if such object was added successfully. Return false if an object with the same airlines, flight number, departure city, year, month, date, and time already exists or currentFlightsCount is already same as maxSize, i.e., the array is full (the new object is not added). |
| boolean removeFlightNumber(String airlines, int flightNumber) | Remove a Flight object from the flight list. Return true if the object was removed successfully. Return false if the object with the given airlines and flight number does not exist. |
| void sortByFlightNumber() | Sort the list of Flight objects by airlines and flight number. This method calls the sort method defined in the Sorts class, using an object of FlightNumberComparator class as its second parameter. You should also make a use of copy() method of Flight class. |
| void sortByDeparture() | Sort the list of Flight objects by their departure information including its city, year, month, date, and time. This method calls the sort method defined in the Sorts class, using an object of DepartureComparator class as its second parameter. You should also make a use of copy() method of Flight class. |
| String listFlights() | List all Flight objects in the flight list. The returned string is the concatenation of each Flight object information in the list for the number of currentFlightsCount (do not use the size of the array here)Hint: you can utilize Flight's toString method to help you complete this method. If there is no object in the list, This method should return the string containing " no flight ". |
| void closeFlightManagement() | Closes the flight management system by making the list empty. This can be done by making every slot of the flightList array to null, and also by setting currentFlightsCount to be 0. |
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.
Assignment8
All input and output should be handled in Assignment8 class. The main method should start by displaying this updated menu in this exact format:
Choice\t\tAction ------\t\t------ A\t\tAdd Flight C\t\tCreate FlightManagement D\t\tSearch by Flight Number E\t\tSearch by Departure L\t\tList Flights O\t\tSort by Flight Number P\t\tSort by Departure Q\t\tQuit R\t\tRemove by Flight Number T\t\tClose FlightManagement U\t\tWrite Text to File V\t\tRead Text from File W\t\tSerialize FlightManagement to File X\t\tDeserialize FlightManagement from File ?\t\tDisplay Help
Next, the following prompt should be displayed:
What action would you like to perform?
Read in the user input and execute the appropriate command. After the execution of each command, redisplay the prompt. Commands should be accepted in both lowercase and uppercase. The following commands are modified or new.
Add Flight
This part is already implemented in Assignment8.java file. Please see the case A in the main of Assignment8.java.
Create FlightManagement
This part is already implemented in Assignment8.java file. Please see the case C in the main of Assignment8.java.
Search by Flight Number
This part is already implemented in Assignment8.java file. Please see the case D in the main of Assignment8.java.
Search by Departure
This part is already implemented in Assignment8.java file. Please see the case E in the main of Assignment8.java.
Sort by Flight Number
This part is already implemented in Assignment8.java file. Please see the case O in the main of Assignment8.java.
Remove by Flight Number
This part is already implemented in Assignment8.java file. Please see the case R in the main of Assignment8.java.
List Flights
Each Flight object information in the flight list should be displayed using the toString method provided in the Flight class. (and use listFlights( ) method in the FlightManagement class.) This part is already implemented in Assignment8.java file. Please see the case L in the main of Assignment8.java.
Close FlightManagement
Delete all Flight objects. Then, display the following:
flight management system closed This part is already implemented in Assignment8.java file. Please see the case R in the main of Assignment8.javaT
Write Text to File
Your program should display the following prompt:
Please enter a file name to write:
Read in the filename and create an appropriate object to get ready to read from the file. Then it should display the following prompts:
Please enter a string to write in the file:
Read in the string that a user types, say "input", then attach " " at the end of the string, and write it to the file. (i.e. input+" " string will be written in the file.)
If the operation is successful, display the following:
FILENAME was written
Replace FILENAME with the actual name of the file.
Use try and catch statements to catch IOException. The file should be closed in a finally statement.
Read Text from File
Your program should display the following prompt:
Please enter a file name to read:
Read in the file name create appropriate objects to get ready to read from the file. If the operation is successful, display the following (replace FILENAME with the actual name of the file):
FILENAME was read
Then read only the first line in the file, and display:
The first line of the file is:
CONTENT
where CONTENT should be replaced by the actual first line in the file.
Your program should catch the exceptions if there are. (Use try and catch statement to catch, FileNotFoundException, and the rest of IOException.)
If the file name cannot be found, display
FILENAME was not found
where FILENAME is replaced by the actual file name.
Serialize FlightManagement to File
Your program should display the following prompt:
Please enter a file name to write:
Read in the filename and write the serialized FlightManagement object out to it. Note that any objects to be stored must implement Serializable interface. The Serializable interface is defined in java.io.* package. If the operation is successful, display the following:
FILENAME was written
Replace FILENAME with the actual name of the file.
Use try and catch statements to catch NotSerializableExeption and IOException.
Deserialize FlightManagement from File
Your program should display the following prompt:
Please enter a file name to read:
Read in the file name and attempt to load the FlightManagement object from that file. Note that there is only one FlightManagement object in the Assignment8 class, and the first object read from the file should be assigned to the FlightManagement object. If the operation is successful, display the following (replace FILENAME with the actual name of the file):
FILENAME was read
Your program should catch the exceptions if there are.
(Use try and catch statement to catch ClassNotFoundException, FileNotFoundException, and the rest of IOException.)
See the output files for exception handling.
output 1 -
Choice Action ------ ------ A Add Flight C Create FlightManagement D Search by Flight Number E Search by Departure L List Flights O Sort by Flight Number P Sort by Departure Q Quit R Remove by Flight Number T Close FlightManagement U Write Text to File V Read Text from File W Serialize FlightManagement to File X Deserialize FlightManagement from File ? Display Help Please enter a maximum number of flights What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Airlines: AA Number: 102 Departure: PHX,1-12-17,7:00am Arrival: SFO,1-12-17,9:00am Airlines: DL Number: 100 Departure: PHX,1-12-17,8:30am Arrival: LAX,1-12-17,9:30am Airlines: AA Number: 202 Departure: LAX,2-12-17,7:00am Arrival: SFO,2-12-17,9:00am What action would you like to perform? Please enter Airlines to search: Please enter flight number to search: flight number AA202 found What action would you like to perform? Please enter Airlines to search: Please enter flight number to search: flight number AA203 not found What action would you like to perform? Please enter Airlines to search: Please enter flight number to search: flight number DL100 found What action would you like to perform? Please enter departure city to search: Please enter its departure year to search: Please enter its departure month to search: Please enter its departure date to search: Please enter its departure time to search: flight departure LAX,1-12-17,8:30am not found What action would you like to perform? Please enter departure city to search: Please enter its departure year to search: Please enter its departure month to search: Please enter its departure date to search: Please enter its departure time to search: flight departure PHX,1-12-17,8:30am found What action would you like to perform? Airlines: AA Number: 102 Departure: PHX,1-12-17,7:00am Arrival: SFO,1-12-17,9:00am Airlines: DL Number: 100 Departure: PHX,1-12-17,8:30am Arrival: LAX,1-12-17,9:30am Airlines: AA Number: 202 Departure: LAX,2-12-17,7:00am Arrival: SFO,2-12-17,9:00am What action would you like to perform? Please enter Airlines to remove: Please enter flight number to remove: flight number AA102 removed What action would you like to perform? Airlines: DL Number: 100 Departure: PHX,1-12-17,8:30am Arrival: LAX,1-12-17,9:30am Airlines: AA Number: 202 Departure: LAX,2-12-17,7:00am Arrival: SFO,2-12-17,9:00am What action would you like to perform? Please enter Airlines to remove: Please enter flight number to remove: flight number AA101 not found What action would you like to perform? Airlines: DL Number: 100 Departure: PHX,1-12-17,8:30am Arrival: LAX,1-12-17,9:30am Airlines: AA Number: 202 Departure: LAX,2-12-17,7:00am Arrival: SFO,2-12-17,9:00am What action would you like to perform? Please enter a file name to write: flight1.dat was written What action would you like to perform? flight management system closed What action would you like to perform? no flight What action would you like to perform? Please enter a file name to read: air1.dat was not found What action would you like to perform? Please enter a file name to read: flight1.dat was read What action would you like to perform? Airlines: DL Number: 100 Departure: PHX,1-12-17,8:30am Arrival: LAX,1-12-17,9:30am Airlines: AA Number: 202 Departure: LAX,2-12-17,7:00am Arrival: SFO,2-12-17,9:00am What action would you like to perform?
output 2 -
Choice Action ------ ------ A Add Flight C Create FlightManagement D Search by Flight Number E Search by Departure L List Flights O Sort by Flight Number P Sort by Departure Q Quit R Remove by Flight Number T Close FlightManagement U Write Text to File V Read Text from File W Serialize FlightManagement to File X Deserialize FlightManagement from File ? Display Help Please enter a maximum number of flights What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Airlines: B6 Number: 361 Departure: PHX,1-12-17,5:00am Arrival: SFO,1-12-17,7:15am Airlines: UA Number: 101 Departure: HOU,10-12-18,9:50am Arrival: ATL,10-12-18,1:35pm Airlines: AA Number: 402 Departure: PHX,3-12-17,7:50pm Arrival: LAX,3-12-17,8:55pm Airlines: BA Number: 1302 Departure: PHX,2-15-17,9:05pm Arrival: LHR,2-16-17,8:15am Airlines: HA Number: 561 Departure: LAX,10-12-17,8:00am Arrival: HNL,10-12-17,12:30pm What action would you like to perform? sorted by departures What action would you like to perform? Airlines: UA Number: 101 Departure: HOU,10-12-18,9:50am Arrival: ATL,10-12-18,1:35pm Airlines: HA Number: 561 Departure: LAX,10-12-17,8:00am Arrival: HNL,10-12-17,12:30pm Airlines: B6 Number: 361 Departure: PHX,1-12-17,5:00am Arrival: SFO,1-12-17,7:15am Airlines: BA Number: 1302 Departure: PHX,2-15-17,9:05pm Arrival: LHR,2-16-17,8:15am Airlines: AA Number: 402 Departure: PHX,3-12-17,7:50pm Arrival: LAX,3-12-17,8:55pm What action would you like to perform? sorted by flight numbers What action would you like to perform? Airlines: AA Number: 402 Departure: PHX,3-12-17,7:50pm Arrival: LAX,3-12-17,8:55pm Airlines: B6 Number: 361 Departure: PHX,1-12-17,5:00am Arrival: SFO,1-12-17,7:15am Airlines: BA Number: 1302 Departure: PHX,2-15-17,9:05pm Arrival: LHR,2-16-17,8:15am Airlines: HA Number: 561 Departure: LAX,10-12-17,8:00am Arrival: HNL,10-12-17,12:30pm Airlines: UA Number: 101 Departure: HOU,10-12-18,9:50am Arrival: ATL,10-12-18,1:35pm What action would you like to perform? Please enter Airlines to remove: Please enter flight number to remove: flight number BA1032 not found What action would you like to perform? Please enter Airlines to remove: Please enter flight number to remove: flight number BA1302 removed What action would you like to perform? Airlines: AA Number: 402 Departure: PHX,3-12-17,7:50pm Arrival: LAX,3-12-17,8:55pm Airlines: B6 Number: 361 Departure: PHX,1-12-17,5:00am Arrival: SFO,1-12-17,7:15am Airlines: HA Number: 561 Departure: LAX,10-12-17,8:00am Arrival: HNL,10-12-17,12:30pm Airlines: UA Number: 101 Departure: HOU,10-12-18,9:50am Arrival: ATL,10-12-18,1:35pm What action would you like to perform? sorted by departures What action would you like to perform? Airlines: UA Number: 101 Departure: HOU,10-12-18,9:50am Arrival: ATL,10-12-18,1:35pm Airlines: HA Number: 561 Departure: LAX,10-12-17,8:00am Arrival: HNL,10-12-17,12:30pm Airlines: B6 Number: 361 Departure: PHX,1-12-17,5:00am Arrival: SFO,1-12-17,7:15am Airlines: AA Number: 402 Departure: PHX,3-12-17,7:50pm Arrival: LAX,3-12-17,8:55pm What action would you like to perform? sorted by flight numbers What action would you like to perform? Airlines: AA Number: 402 Departure: PHX,3-12-17,7:50pm Arrival: LAX,3-12-17,8:55pm Airlines: B6 Number: 361 Departure: PHX,1-12-17,5:00am Arrival: SFO,1-12-17,7:15am Airlines: HA Number: 561 Departure: LAX,10-12-17,8:00am Arrival: HNL,10-12-17,12:30pm Airlines: UA Number: 101 Departure: HOU,10-12-18,9:50am Arrival: ATL,10-12-18,1:35pm What action would you like to perform?
output 3-
Choice Action ------ ------ A Add Flight C Create FlightManagement D Search by Flight Number E Search by Departure L List Flights O Sort by Flight Number P Sort by Departure Q Quit R Remove by Flight Number T Close FlightManagement U Write Text to File V Read Text from File W Serialize FlightManagement to File X Deserialize FlightManagement from File ? Display Help Please enter a maximum number of flights What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Airlines: UA Number: 2043 Departure: HOU,10-12-18,9:50am Arrival: ATL,10-12-18,1:35pm Airlines: AA Number: 2345 Departure: PHX,3-12-17,7:50pm Arrival: LAX,3-12-17,8:55pm Airlines: DL Number: 3241 Departure: PHX,1-12-18,8:30am Arrival: LAX,1-12-18,9:00am Airlines: B6 Number: 1120 Departure: ORD,4-16-17,9:35am Arrival: PHX,4-16-17,4:30pm What action would you like to perform? Please enter Airlines to search: Please enter flight number to search: flight number DL3241 found What action would you like to perform? Please enter Airlines to search: Please enter flight number to search: flight number DL1234 not found What action would you like to perform? Please enter departure city to search: Please enter its departure year to search: Please enter its departure month to search: Please enter its departure date to search: Please enter its departure time to search: flight departure ORD,4-16-17,9:35am found What action would you like to perform? Airlines: UA Number: 2043 Departure: HOU,10-12-18,9:50am Arrival: ATL,10-12-18,1:35pm Airlines: AA Number: 2345 Departure: PHX,3-12-17,7:50pm Arrival: LAX,3-12-17,8:55pm Airlines: DL Number: 3241 Departure: PHX,1-12-18,8:30am Arrival: LAX,1-12-18,9:00am Airlines: B6 Number: 1120 Departure: ORD,4-16-17,9:35am Arrival: PHX,4-16-17,4:30pm What action would you like to perform? sorted by flight numbers What action would you like to perform? Airlines: AA Number: 2345 Departure: PHX,3-12-17,7:50pm Arrival: LAX,3-12-17,8:55pm Airlines: B6 Number: 1120 Departure: ORD,4-16-17,9:35am Arrival: PHX,4-16-17,4:30pm Airlines: DL Number: 3241 Departure: PHX,1-12-18,8:30am Arrival: LAX,1-12-18,9:00am Airlines: UA Number: 2043 Departure: HOU,10-12-18,9:50am Arrival: ATL,10-12-18,1:35pm What action would you like to perform? sorted by departures What action would you like to perform? Airlines: UA Number: 2043 Departure: HOU,10-12-18,9:50am Arrival: ATL,10-12-18,1:35pm Airlines: B6 Number: 1120 Departure: ORD,4-16-17,9:35am Arrival: PHX,4-16-17,4:30pm Airlines: AA Number: 2345 Departure: PHX,3-12-17,7:50pm Arrival: LAX,3-12-17,8:55pm Airlines: DL Number: 3241 Departure: PHX,1-12-18,8:30am Arrival: LAX,1-12-18,9:00am What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Airlines: UA Number: 2043 Departure: HOU,10-12-18,9:50am Arrival: ATL,10-12-18,1:35pm Airlines: B6 Number: 1120 Departure: ORD,4-16-17,9:35am Arrival: PHX,4-16-17,4:30pm Airlines: AA Number: 2345 Departure: PHX,3-12-17,7:50pm Arrival: LAX,3-12-17,8:55pm Airlines: DL Number: 3241 Departure: PHX,1-12-18,8:30am Arrival: LAX,1-12-18,9:00am Airlines: WN Number: 5234 Departure: DEN,3-20-17,6:35pm Arrival: PHX,3-20-17,11:55pm What action would you like to perform? Please enter Airlines to search: Please enter flight number to search: flight number WN5235 not found What action would you like to perform? Please enter Airlines to search: Please enter flight number to search: flight number WN5234 found What action would you like to perform? Airlines: UA Number: 2043 Departure: HOU,10-12-18,9:50am Arrival: ATL,10-12-18,1:35pm Airlines: B6 Number: 1120 Departure: ORD,4-16-17,9:35am Arrival: PHX,4-16-17,4:30pm Airlines: AA Number: 2345 Departure: PHX,3-12-17,7:50pm Arrival: LAX,3-12-17,8:55pm Airlines: DL Number: 3241 Departure: PHX,1-12-18,8:30am Arrival: LAX,1-12-18,9:00am Airlines: WN Number: 5234 Departure: DEN,3-20-17,6:35pm Arrival: PHX,3-20-17,11:55pm What action would you like to perform? Please enter a file name to write: Please enter a string to write in the file: example1.txt was written What action would you like to perform? Please enter a file name to read: example2.txt was not found What action would you like to perform? Please enter a file name to read: example1.txt was read The first line of the file is: Writing and writing What action would you like to perform? Airlines: UA Number: 2043 Departure: HOU,10-12-18,9:50am Arrival: ATL,10-12-18,1:35pm Airlines: B6 Number: 1120 Departure: ORD,4-16-17,9:35am Arrival: PHX,4-16-17,4:30pm Airlines: AA Number: 2345 Departure: PHX,3-12-17,7:50pm Arrival: LAX,3-12-17,8:55pm Airlines: DL Number: 3241 Departure: PHX,1-12-18,8:30am Arrival: LAX,1-12-18,9:00am Airlines: WN Number: 5234 Departure: DEN,3-20-17,6:35pm Arrival: PHX,3-20-17,11:55pm What action would you like to perform?
output4 -
Choice Action ------ ------ A Add Flight C Create FlightManagement D Search by Flight Number E Search by Departure L List Flights O Sort by Flight Number P Sort by Departure Q Quit R Remove by Flight Number T Close FlightManagement U Write Text to File V Read Text from File W Serialize FlightManagement to File X Deserialize FlightManagement from File ? Display Help Please enter a maximum number of flights What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight not added What action would you like to perform? Airlines: B6 Number: 345 Departure: PHX,2-12-17,12:00pm Arrival: SFO,2-12-17,2:10pm Airlines: AA Number: 235 Departure: SEA,2-23-17,1:55pm Arrival: PHX,2-23-17,6:40pm What action would you like to perform? Please enter a new maximum number of flights: What action would you like to perform? no flight What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight added What action would you like to perform? Please enter a flight to add: Please enter its airlines to add: Please enter its flight number to add: Please enter its departure city to add: Please enter its departure year to add: Please enter its departure month to add: Please enter its departure date to add: Please enter its departure time to add: Please enter its arrival city to add: Please enter its arrival year to add: Please enter its arrival month to add: Please enter its arrival date to add: Please enter its arrival time to add: flight not added What action would you like to perform? Airlines: DL Number: 51 Departure: EWR,3-3-17,11:23am Arrival: DEN,3-3-17,5:00pm Airlines: AA Number: 4325 Departure: PHX,2-23-17,1:55pm Arrival: SEA,2-23-17,6:40pm What action would you like to perform? sorted by departures What action would you like to perform? Airlines: DL Number: 51 Departure: EWR,3-3-17,11:23am Arrival: DEN,3-3-17,5:00pm Airlines: AA Number: 4325 Departure: PHX,2-23-17,1:55pm Arrival: SEA,2-23-17,6:40pm What action would you like to perform? sorted by flight numbers What action would you like to perform? Airlines: AA Number: 4325 Departure: PHX,2-23-17,1:55pm Arrival: SEA,2-23-17,6:40pm Airlines: DL Number: 51 Departure: EWR,3-3-17,11:23am Arrival: DEN,3-3-17,5:00pm What action would you like to perform?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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
