Question: In this project, you will implement an airport system. In this system, we keep the flight details in a file. Please see image 1




In this project, you will implement an airport system. In this system, we keep the flight details in a file. Please see image 1 for our input file. In this file, there are 9 flights whose origin is our airport. In each line, you see the destination code, flight time, flight code (airline and flight code actually but consider them combined), eco price, flex price and business price. E.g. JFK 16.20 TK001 1200 1800 5700 means there is a flight from our airport which will go to JFK airport at 16.20 with flight code TK001. Prices for eco, flex and business seats are 1200, 1800 and 5700 dollars. O cost: int[] in.txt JFK 16.20 TK001 1200 1800 5700 LAX 18.20 VR65 450 650 2300 IST 1.20 KLM12 1000 2000 4000 ACA 2.30 AA23 660 780 1100 ACC 11.30 DL11 310 540 900 NW 4.50 KLM24 450 670 1200 CO 14.40 VR34 500 600 900 LAX 23.20 VR66 450 650 2300 ACC 18.30 DL12 310 540 900 STEP 1 - Create a Flight class. In this class, you will: declare 4 private variables: O destination: String O time: String code: String methods as: Image 1 - input file: in.txt O 2 constructors no-arg all strings to empty string initialize cost array to have 3 elements (for eco, flex and business) arguments as: String, String, String, int, int, int all strings to empty string initialize cost array to have 3 elements all costs initialized with given arguments O 1 set method (String, String, String, int, int, int) to setup all variables all setters and getters of instance variables O STEP 2 -Create a file similar to above (you can use the same). STEP 3 Now, create a driver class for testing purposes. This class has a main method and a method: int returnArrayIndex (String code). In the main method: Create a Flight array of number of items in your text file (for the given example, it is 9) Create an integer array of the same number of items to keep reservations. This array will increment the number of reservations for chosen flight. Read the file. AS YOU READ YOUR FILE, YOU HAVE TO HANDLE EXCEPTIONS IN A TRY_CATCH BLOCK BY USING FileNotFoundException. How to read a file (this example is without exceptions but you need to add exceptions, too): File myObj = new File("in.txt"); Scanner myReader = new Scanner (myObj); while (myReader.hasNextLine()) { String data = myReader.nextLine(); // DO anything you need......... } myReader.close(); O O o O You are free to use any method to read your file. You can read char by char, word by word or line by line. The above example reads the line, so the programmer needs to split it to destination, time, code and costs. Initialize your Flight objects in the array with the read information. Show Options to the user and ask what they want: 1: See all flights 2: Make a reservation 3: Airport based flights 0: Exit If 1-show all flights If 2 - ask the code. Find the index of this code in the reservations array by using a helper method (returnArrayIndex). returnArrayIndex method returns the array index of any given flight code, e.g. "TK001" 0; VR65" 1; KLM12" 2; etc.. Increment the value of the given code in the reservations array. Print it. If 3, show airport based flights. If 4, exit. For all cases, see the below sample output and be consistent with it. Press: 1: See all flights 2: Make a reservation 3: Airport based flights 0: Exit 1 Flight Details for Flight 1 Destination is: JFK Time is: 16.20 Code is: TK001 Eco price is: 1200 Flex price is: 1800 Business price is: 5700 Flight Details for Flight 2 Destination is: LAX Time is: 18.20 Code is: VR65 Eco price is: 450 Flex price is: 650 Business price is: 2300 Flight Details for Flight 3 Destination is: IST Time is: 1.20 Code is: KLM12 Eco price is: 1000 Flex price is: 2000 Business price is: 4000 Flight Details for Flight 4 Destination is: ACA Time is: 2.30 Code is: AA23 Eco price is: 660 Flex price is: 780 Business price is: 1100 Flight Details for Flight 5 Destination is: ACC Time is: 11.30 Code is: DL11 Eco price is: 310 Flex price is: 540 Business price is: 900 Flight Details for Flight 6 Destination is: NW Time is: 4.50 Code is: KLM24 Eco price is: 450 Flex price is: 670 Business price is: 1200 Flight Details for Flight 7 Destination is: CO Time is: 14.40 Code is: VR34 Eco price is: 500 Flex price is: 600 Business price is: 900 Flight Details for Flight 8 Destination is: LAX Time is: 23.20 Code is: VR66 Eco price is: 450 Flex price is: 650 Business price is: 2300 Flight Details for Flight 9 Destination is: ACC Time is: 18.30 Code is: DL12 Eco price is: 310 Flex price is: 540 Business price is: 900 Press: 1: See all flights 2: Make a reservation 3: Airport based flights 0: Exit 2 Enter the flight code: VR65 Number of reservations in this flight is: 1 Press: 1: See all flights 2: Make a reservation 3: Airport based flights 0: Exit 2 Enter the flight code: VR65 Number of reservations in this flight is:2 Press: 1: See all flights. 2: Make a reservation 3: Airport based flights 0: Exit 3 Airport workloads are: TK001 VR65 VR66 JFK: 1 LAX: 2 - IST: 1 KLM12 ACA: 1 ACC: 2 NW: 1 CO: 1 AA23 DL11 DL12 KLM24 VR34 Press: 1: See all flights 2: Make a reservation 3: Airport based flights 0: Exit 0 Thank you for visiting us!!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
