” 写作INFO1113程序、 辅导Java编程语言INFO1113 Assignment 1Due: 23 April 2021, 11:59PM AESTThis assignment is worth 12% of your final grade.Task Description Flight SchedulerIn this assignment, you will create a Flight Scheduler application in the Java programming language. Theprogram will be a tool for airlines to use to schedule flights between different locations, producingtimetable plans, and an easy way to check routing between cities on multiple flights. You must create atleast three classes: FlightScheduler, Flight and Location, for which a scaffold and description have beenprovided to you. The FlightScheduler class will contain the main entry point of the application (static mainfunction).You are encouraged to ask questions on Ed under the assignments category if you are unsure of thespecification but staff members will not be able to do any coding or debugging in this assignment foryou. As with any assignment, make sure that your work is your own, and do not share your code orsolutions with other students.Working on your assignmentYou can work on this assignment on your own computer or the lab machines. It is important that youcontinually back up your assignment files onto your own machine, external drives, and in the cloud.You are encouraged to submit your assignment on Ed while you are in the process of completing it. Bysubmitting you will obtain some feedback of your progress on the sample test cases provided.INFO1113Page 2 of 17Implementation detailsWrite a program in Java to implement the Flight Schedular application that accepts input from the uservia standard input. The terminal interface allows the user to interact with the program, to give it inputand receive output. The available commands are described below in the section Commands.There are three main classes you must implement, but you may also create more if you wish.FlightScheduler classThis class will contain the main entry point of your program (static main function) and store links to all thedata relevant to the application. It will be a container for the flight schedule, which is made up of a list ofFlights. It should also contain a list of Locations.The flight schedule is only a single week, Monday to Sunday, which repeats. Assume all times are in UTC,so you do not have to Account for timezone differences at different locations.Flight classThe Flight type should contain all data relevant to a particular flight, methods that perform operations ona Flight or multiple Flights. Attributes will be the flight ID, departure time, source and destinationlocations, capacity, ticket price, number of passengers booked, and anything else you think is relevant.Flight duration is determined by the distance between the start and end locations, calculated using theHaversine Formula, and assuming the average speed of an aircraft is 720km/h. The initial ticket price iscalculated using an average cost of $30, plus 4x the demand coefficient differential between locations,per 100km distance. For example, if the starting location has demand coefficient of -1 and the end has -1,it remains $30 per 100km. If the starting location has -1 and the end has 1, then its $38 per 100km. If thestarting location has 1 and end has -1, it would be $22 per 100km.Ticket price changes when the flight starts to fill up. For the first 50% of seats, the price decreases linearlyto 80% of its original value by the time the flight is half full. For the next 20% of seats, the price increaseslinearly back to 100% of its original value. For the last 30% of seats, ticket price increases by an inversetancurve to 110% of its original value, except for the last 10 seats, which each will increase the price by1% each time they are booked. Seat proportions are to be rounded down. = 0.4 + 1, 0 0.5 + 0.3, 0.5 0.70.2 tan(20 14) + 1 , 0.7 1 = 100 (30 + 4 )whereT = ticket pricey = multiplier for ticket Price to determine current valuex = proportion of seats filled (booked/capacity)d = flight distance in kilometres (haversine formula result)Dto = demand coefficient for destination locationDfrom = demand coefficient for starting locationINFO1113Page 3 of 17Location classThe Location type should contain all data relevant to a particular location, and methods that performoperations on a Location or multiple Locations. Attributes will be the location name, latitude andlongitude coordinates, lists of arriving and departing flights, and a demand coefficient. Location namesmust be unique (case insensitive). Latitude must be within [-85, 85] and longitude must be within [-180,180], both in degrees. The demand coefficient is a number between -1 and 1 (inclusive) whichrepresents whether there is a net inflow or outflow of passengers from this location (negative meanspassengers want to leave, positive means they want to come). It factors into the calculation thatdetermines the ticket price for a particular flight.Assume each location has only one runway that is, no flights can be scheduled to arrive or depart withinan hour of another at a particular location. Multi-runway airports can be represented by multiplelocations in such a system (eg. Heathrow-1, Heathrow-2, etc).INFO1113Page 4 of 17CommandsFLIGHTS – list all available flights ordered by departure time, then departure location nameFLIGHT ADD departure time from to capacity – add a flightFLIGHT IMPORT/EXPORT filename – import/export flights to csv fileFLIGHT id – view information about a flight (from-to, departure arrival times, current ticket price,capacity, passengers booked)FLIGHT id BOOK num – book a Certain number of passengers for the flight at the current ticket price,and then adjust the ticket price to reflect the reduced capacity remaining. If no number is given, book 1passenger. If the given number of bookings is more than the remaining capacity, only accept bookingsuntil the capacity is full.FLIGHT id REMOVE – remove a flight from the scheduleFLIGHT id RESET – reset the number of passengers booked to 0, and the ticket price to its original state.LOCATIONS – list all available locations in alphabetical orderLOCATION ADD name lat long demand_coefficient – add a locationLOCATION name – view details about a location (its name, coordinates, demand coefficient)LOCATION IMPORT/EXPORT filename – import/export locations to csv fileSCHEDULE location_name – list all departing and arriving flights, in order of the time they arrive/departDEPARTURES location_name – list all departing flights, in order of departure timeARRIVALS location_name – list all arriving flights, in order of arrival timeTRAVEL from to [sort] [n] – list the nth possible flight route between a starting location anddestination, with a maximum of 3 stopovers. Default ordering is for shortest overall duration. If n is notprovided, display the first one in the order. If n is larger than the number of flights available, display thelast one in the ordering.can have other orderings:TRAVEL from to cost – minimum current costTRAVEL from to duration – minimum total durationTRAVEL from to stopovers – minimum stopoversTRAVEL from to layover – minimum layover timeTRAVEL from to flight_time – minimum flight timeHELP outputs this help string.EXIT end the program.Note: All commands may be case insensitive.However Location names when stored in the location class, should display the name as initially given.INFO1113Page 5 of 17Travel commandSince the schedule is weekly and wraps around, you need to consider the possibility of a flight arriving onSunday evening potentially connecting With a flight that departs on Monday morning. As such, you mayignore available seat capacity selecting a flight in a potential route, since it is assumed that the currentbookings are only for the current week, and this flight route may be used to show results for travellers insubsequent weeks, looking to make a booking later on. However, the ticket prices and overall route costshould depend on the current booking numbers of each flight, since we are assuming that the currentbooking demand is a good indicator of future demand, so ticket prices will be similar in the future to whatthey are now.The TRAVEL command has 5 potential orderings, detailed below. If the primary sorting property is equalbetween two flight paths, it will fall back to the following secondary and tertiary sorting properties. It isassumed that current cost will never be equal for two flight paths (this may not be true in practice, butthen any secondary ordering is fine). If total duration is equal, sort then by minimum current cost. Total duration is the time taken frominitial departure of the first flight, to finally arriving at the destination. If number of stopovers is equal, sort then by minimum total duration (and then by minimumcost). Stopovers are intermediary locations travelled to in order to reach the destination. If layover time is equal, sort then by minimum total duration (and then by minimum cost).Layover time is the time spent waiting at the airport for connecting flights. If flight time is equal, sort then by minimum total duration (and then by minimum cost). Flighttime is the time spent onboard the aircraft while it is flying (ie. total duration excluding layovertime).The output format of the travel command is composed of the flight plan, with layover times betweenflights specified, see the examples section below.Note: The number of stopovers is the number of intermediary destinations, not including the originalstarting location and final destination. It is equivalent to the number of flight legs minus 1.INFO1113Page 6 of 17Error messagesThe following messages should be output upon encountering the prescribed error case or condition:command Description of condition/error case Message outputflight add Time added was not in the Correctformat, for example Monday 18:00Invalid departure time. Use the formatday_of_week hour:minute, with 24htime.Starting location was not in thedatabase.Invalid starting location.Ending location was not in the database. Invalid ending location.Capacity was not a positive integer. Invalid positive integer capacity.The two locations entered were thesame.Source and destination cannot be the sameplace.No runways are available for this flightat the designated location at that time.DateTime is in the format as above,Monday 18:00Scheduling conflict! This flight clashes withFlight ID departing from Location onDateTime.No runways are available for this flightat the designated location at that time.DateTime is in the format as above,Monday 18:00Scheduling conflict! This flight clashes withFlight ID arriving at Location onDateTime.Not enough command arguments given. Usage: FLIGHT ADD departure timefrom to capacity\nExample: FLIGHTADD Monday 18:00 Sydney Melbourne 120flight book The number of passengers entered wasnot a valid positive integer.Invalid number of passengers to book.If the capacity is full, Print this after eachattempt at booking that wouldotherwise exceed the capacity, or hasfilled it.Flight is now full.flightremoveRemove this flight display the shortdeparture time, eg. Mon 18:00, andthen source destination locations.Removed Flight ID, DateTime Location– Location, from the flight schedule.flight reset Display the short departure time, eg.Mon 18:00, and then source destination locations.Reset passengers booked to 0 for Flight ID,DateTime Location — Location.flight id Invalid flight id is entered that is eithernot a number, or does not exist in thedatabase.Invalid Flight ID.flight no parameters given Usage:\nFLIGHT id [BOOK/REMOVE/RESET][num]\nFLIGHT ADD departure timefrom to capacity\nFLIGHTIMPORT/EXPORT filenameimport No filename is given, or the file doesntexist.Error reading file.export No filename is given, or the directory forthis file doesnt exist.Error writing file.INFO1113Page 7 of 17flights/locationsNo flights/locations Are available printthis instead of the flight/location listing(None)locationaddLocation is already present in thedatabase (case insensitive based onname)This location already exists.Latitude exceeds bounds or is an invalidnumber.Invalid latitude. It must be a number ofdegrees between -85 and +85.Longitude exceeds bounds or is aninvalid numberInvalid longitude. It must be a number ofdegrees between -180 and +180.Demand coefficient exceeds bounds oris an invalid number.Invalid demand coefficient. It must be anumber between -1 and +1.location Location is not present in the database(case insensitive based on name)Invalid location name.location No parameters given. Usage:\nLOCATION name\nLOCATION ADDname latitude longitudedemand_coefficient\nLOCATIONIMPORT/EXPORT filenameSchedule,departures,arrivalsLocation is not present in the database(case insensitive based on name)This location does Not exist in the system.travel Starting location is not present in thedatabase (case insensitive based onname.Starting location not found.Ending location is not present in thedatabase (case insensitive based onname.Ending location not found.Bad sorting property. Invalid sorting property: must be either cost,duration, stopovers, layover, or flight_time.No flight paths of 3 stopovers or less areavailable from the given startinglocation to the ending destination.Sorry, no flights with 3 or less stopovers areavailable from Location to Location.No parameters given. Usage: TRAVEL from to[cost/duration/stopovers/layover/flight_time]INFO1113Page 8 of 17CSV file formatsThe import and export command for flights and locations allow the contents of the flight and locationdatabases within the program to be saved to CSV (comma separated values) files. Two example files havebeen provided, as well as a sample command input/output sequence below.When importing and exporting, if invalid lines are encountered in the file without the required data, skipthem and display the total number of errors at the end, if any were invalid. For example:User: location import locations.csvImported 23 locations.1 line was invalid.User: flight import flights.csvImported 23 flights.3 lines were invalid.User: flight import flights2.csvImported 1 flight.User: flight export flights3.csvExported 1 flight.Flights and locations are to be imported in the order they are given in the file.Flights csv has the Following format: day time,startLocation,endLocation,capacity,bookedExample:Monday 18:00,Sydney,Melbourne,120,80Monday 19:00,Sydney,Hobart,120,29Monday 21:30,Sydney,Hobart,120,29Monday 18:00,Auckland,Rio,120,1Locations csv has the following format: locationName,latitude,longitude,demandCoefficientExample:Sydney,-33.847927,150.651786,0.4Hobart,-42.8823399,147.3198016,0.1Perth,-32.0397559,115.681346,0.5Adelaide,-35.0004451,138.3309716,0.1CoffsHarbour,-30.2973943,153.0286009,-0.2Brisbane,-27.4732824,152.747337,0.3INFO1113Page 9 of 17Examples Input/Output formatFormat of FLIGHTS command sorted by departure time:Flights——————————————————-ID Departure Arrival Source — Destination——————————————————-0 Mon 17:00 Mon 17:04 Brisbane — GoldCoast1 Mon 18:05 Mon 18:09 Brisbane — GoldCoast2 Mon 19:05 Mon 19:09 Brisbane — GoldCoastFormat of flight id command:Flight 0Departure: Mon 00:05 BerlinArrival: Mon 08:57 NewYorkDistance: 6,387kmDuration: 8h 52mTicket Cost: $1724.01Passengers: 0/189Format of locations command sorted by alphabetical order:Locations (3):Berlin, London, NewYorkFormat of location name command:Location: HobartLatitude: -42.882340Longitude: 147.319802Demand: +0.5000Format of travel command:User: travel sydney londonStopovers: 3Total Duration: 34h 36mTotal Cost: $5172.49————————————————————-ID Cost Departure Arrival Source — Destination————————————————————-5 $ 3399.00 Wed 10:00 Thu 02:44 Sydney — AbuDhabiLAYOVER 1h 16m at AbuDhabi10 $ 1384.44 Thu 04:00 Thu 11:11 AbuDhabi — OsloLAYOVER 7h 49m at Oslo20 $ 389.05 Thu 19:00 Thu 20:36 Oslo — LondonINFO1113Page 10 of 17Examples (1)$ java FlightSchedulerUser: location add Berlin 52.5 13.15 0.22222Successfully added location Berlin.User: location add NewYork 40.7 -74.26 -0.874Successfully Added location NewYork.User: flight add sunday 20:00 Berlin NewYork 250Successfully added Flight 0.User: flight 0Flight 0Departure: Sun 20:00 BerlinArrival: Mon 04:52 NewYorkDistance: 6,387kmDuration: 8h 52mTicket Cost: $1636.01Passengers: 0/250User: flightsFlights——————————————————-ID Departure Arrival Source — Destination——————————————————-0 Sun 20:00 Mon 04:52 Berlin — NewYorkUser: flight add monday 05:00 newYork berlin 234Successfully added Flight 1.User: flightsFlights——————————————————-ID Departure Arrival Source — Destination——————————————————-1 Mon 05:00 Mon 13:52 NewYork — Berlin0 Sun 20:00 Mon 04:52 Berlin — NewYorkUser: exitApplication closed.INFO1113Page 11 of 17Examples (2)$ java FlightSchedulerUser: flight import flights.csvImported 0 flights.3 lines were invalid.User: location import locations.csvImported 51 locations.User: locationsLocations (51):AbuDhabi, Adelaide, AliceSprings, Alta, Athens, Auckland, Beijing,Berlin, Bern, Bordeaux, Brisbane, Cairo, Cardiff, Chicago,CoffsHarbour, Dallas, Darwin, Dubai, Dubbo, GoldCoast, Hanoi, Hobart,Houston, Jakarta, Johannesburg, Lagos, Liverpool, London, Longyearbyen,LosAngeles, Luton, Madrid, Manchester, Moscow, NewYork, Orange, Oslo,Paris, Perth, Rio, Rome, SanFrancisco, Stockholm, Sydney, Toulouse,Townsville, Tromso, Ufa, Utqiagvik, Vladivostok, WashingtonUser: flights import flights.csvFlights——————————————————-ID Departure Arrival Source — Destination——————————————————-(None)User: flight import Flights.csvImported 2 flights.1 line was invalid.User: flightsFlights——————————————————-ID Departure Arrival Source — Destination——————————————————-0 Mon 19:00 Mon 20:27 Sydney — Hobart1 Mon 21:30 Mon 22:57 Sydney — HobartUser: flight 0Flight 0Departure: Mon 19:00 SydneyArrival: Mon 20:27 HobartDistance: 1,045kmDuration: 1h 27mTicket Cost: $272.00Passengers: 29/120User: flight 1Flight 1Departure: Mon 21:30 SydneyArrival: Mon 22:57 HobartDistance: 1,045kmDuration: 1h 27mTicket Cost: $272.00Passengers: 29/120User: exitApplication closed.INFO1113Page 12 of 17Examples (3)User: location Import locations.csvImported 51 locations.User: flight add wednesday 6:00 sydney perth 180Successfully added Flight 0.User: flight add wednesday 8:00 sydney perth 180Successfully added Flight 1.User: flight 0Flight 0Departure: Wed 06:00 SydneyArrival: Wed 10:31 PerthDistance: 3,254kmDuration: 4h 31mTicket Cost: $989.16Passengers: 0/180User: flight 0 book 20Booked 20 passengers on flight 0 for a total cost of $19365.60User: flight 0 book 20Booked 20 passengers on flight 0 for a total cost of $18486.35User: flight 0 book 20Booked 20 passengers on flight 0 for a total cost of $17607.09User: fligh1 book 100Invalid command. Type help for a list of commands.User: fligh 1 book 100Invalid command. Type help for a list of commands.User: flight 1 book 100Booked 100 passengers on flight 1 for a total cost of $88381.66User: flight 0Flight 0Departure: Wed 06:00 SydneyArrival: Wed 10:31 PerthDistance: 3,254kmDuration: 4h 31mTicket Cost: $857.27Passengers: 60/180User: flight 1Flight 1Departure: Wed 08:00 SydneyArrival: Wed 12:31 PerthDistance: 3,254kmDuration: 4h 31mTicket Cost: $846.28Passengers: 100/180User: flight add wednesday 11:31 perth johannesburg 230Successfully added Flight 2.User: fligh 2INFO1113Page 13 of 17Invalid command. Type help for a list of commands.User: flight 2Flight 2Departure: Wed 11:31 PerthArrival: Wed 23:03 JohannesburgDistance: 8,303kmDuration: 11h 32mTicket Cost: $2163.44Passengers: 0/230User: flight add thursday 01:00 johannesburg London 220Successfully added Flight 3.User: flight add friday 01:00 johannesburg London 220Successfully added Flight 4.User: flight add satursday 01:00 johannesburg London 220Invalid departure time. Use the format day_of_week hour:minute,with 24h time.User: flight add saturday 01:00 johannesburg London 220Successfully added Flight 5.User: flightsFlights——————————————————-ID Departure Arrival Source — Destination——————————————————-0 Wed 06:00 Wed 10:31 Sydney — Perth1 Wed 08:00 Wed 12:31 Sydney — Perth2 Wed 11:31 Wed 23:03 Perth — Johannesburg3 Thu 01:00 Thu 13:36 Johannesburg — London4 Fri 01:00 Fri 13:36 Johannesburg — London5 Sat 01:00 Sat 13:36 Johannesburg — LondonUser: flight export flights3.csvExported 6 flights.User: exitApplication closed.Examples (4)User: location import locations.csvImported 51 locations.User: location import locations4.csvImported 2 locations.User: flight import flights6.csvImported 182 flights.User: travel sydney londonStopovers: 3Total Duration: 34h 36mTotal Cost: $5172.49————————————————————-INFO1113Page 14 of 17ID Cost Departure Arrival Source — Destination————————————————————-5 $ 3399.00 Wed 10:00 Thu 02:44 Sydney — AbuDhabiLAYOVER 1h 16m at AbuDhabi10 $ 1384.44 Thu 04:00 Thu 11:11 AbuDhabi — OsloLAYOVER 7h 49m at Oslo20 $ 389.05 Thu 19:00 Thu 20:36 Oslo — LondonUser: exitApplication closed.Examples (5)User: location import locations.csvImported 51 locations.User: location import locations4.csvImported 2 locations.User: flight import flights6.csvImported 182 flights.User: schedule sydneySydney——————————————————-ID Time Departure/Arrival to/from Location——————————————————-166 Mon 10:30 Depature to Dubai100 Mon 12:00 Depature to Jakarta103 Mon 13:33 Arrival from AbuDhabi89 Mon 19:00 Depature to Hobart90 Mon 21:30 Depature to Hobart173 Tue 02:38 Arrival from AliceSprings174 Tue 04:00 Depature to AliceSprings69 Tue 05:00 Depature to LosAngeles99 Tue 08:27 Arrival from Hobart0 Wed 09:00 Depature to Beijing5 Wed 10:00 Depature to AbuDhabi161 Wed 11:00 Depature to LosAngeles162 Wed 13:00 Depature to Dubbo165 Wed 15:23 Arrival from Dubbo163 Wed 18:00 Depature to Orange164 Wed 20:14 Arrival from Orange6 Thu 04:44 Arrival from AbuDhabi3 Thu 11:11 Arrival from Hanoi131 Fri 14:00 Depature to AbuDhabi113 Sat 04:00 Depature to Perth114 Sat 06:00 Depature to Perth112 Sat 09:00 Depature to PerthUser: arrivals sydneySydney——————————————————-ID Time Departure/Arrival to/from Location——————————————————-103 Mon 13:33 Arrival from AbuDhabi173 Tue 02:38 Arrival from AliceSprings99 Tue 08:27 Arrival from Hobart165 Wed 15:23 Arrival from Dubbo164 Wed 20:14 Arrival from OrangeINFO1113Page 15 of 176 Thu 04:44 Arrival from AbuDhabi3 Thu 11:11 Arrival from HanoiUser: departures sydneySydney——————————————————-ID Time Departure/Arrival to/from Location——————————————————-166 Mon 10:30 Departure to Dubai100 Mon 12:00 Departure to Jakarta89 Mon 19:00 Departure to Hobart90 Mon 21:30 Departure to Hobart174 Tue 04:00 Departure to AliceSprings69 Tue 05:00 Departure to LosAngeles0 Wed 09:00 Departure to Beijing5 Wed 10:00 Departure to AbuDhabi161 Wed 11:00 Departure to LosAngeles162 Wed 13:00 Departure to Dubbo163 Wed 18:00 Departure to Orange131 Fri 14:00 Departure to AbuDhabi113 Sat 04:00 Departure to Perth114 Sat 06:00 Departure to Perth112 Sat 09:00 Departure to PerthUser: arrivals perthPerth——————————————————-ID Time Departure/Arrival to/from Location——————————————————-169 Mon 17:52 Arrival from AliceSprings113 Sat 08:31 Arrival from Sydney114 Sat 10:31 Arrival from Sydney112 Sat 13:31 Arrival from SydneyUser: departures perthPerth——————————————————-ID Time Departure/Arrival to/from Location——————————————————-145 Mon 00:00 Departure to Johannesburg171 Mon 15:05 Departure to AliceSprings170 Mon 16:05 Departure to AliceSprings115 Thu 06:00 Departure to Mumbai132 Fri 13:00 Departure to AbuDhabiUser: schedule perthPerth——————————————————-ID Time Departure/Arrival to/from Location——————————————————-145 Mon 00:00 Depature to Johannesburg171 Mon 15:05 Depature to AliceSprings170 Mon 16:05 Depature to AliceSprings169 Mon 17:52 Arrival from AliceSprings115 Thu 06:00 Depature to Mumbai132 Fri 13:00 Depature to AbuDhabi113 Sat 08:31 Arrival from Sydney114 Sat 10:31 Arrival from Sydney112 Sat 13:31 Arrival from SydneyUser: exitApplication closed.INFO1113Page 16 of 17Writing your own testcasesWe have provided you with some test cases but these do not test all the functionality described in the\r\”
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。