Supplied file(s)
(copy from $sup05)
DemoFlightRoutes.jar (the demo executable)
FlightRoutes.txt (the TextItems file of program description)
flights_world.txt (a sample input file of flight route data)
The following files are from zyBook Section 10.7:
Graph.java (the Graph class for the Graph implementation)
Vertex.java (the Vertex class for the Graph implementation)
Edge.java (the Edge class for the Graph implementation)
Files to submit FlightRoutes.jar (your executable jar file)
FlightRoutes.java (your source code file)
my_tests.sh (your completed testing script)
Where to put them Copy them to your u##/submissions/s05 folder
When they're due Sun, Nov 30, 2025 @11:59pm

Overview

This week your task is to write a program that can read an input file of text containing information about airplane flight routes and display a list of all routes to or from a given city, along with the distance in miles between the cities on each route. On each run of the program the user must supply the file containing all the information, the name of the city of interest, and whether the user is requesting a list of all flights to the city or from the city.

Once again your final result must be an executable jar file that performs in the same way as the demo executable.

Steps to Perform

  1. Begin by copying the supplied files to your working directory in your uxx account.
  2. Run the demo executable file with no command-line input and study the program description.
  3. Next study the sample input file sample_flight_data.txt and note the format (which is described below). Then run the demo executable with this file input, along with either "to" or "from" and the name of one of the cities in the file. Continue this experimentation until you understand how your program is to work, since its behavior must replicate the behavior of the sample executable.
  4. Now design, and then write, a Java program that will emulate as closely as possible the behavior of the sample executable. By now you should be familiar with the zyBook discussion of the graph data structure, up to and including zyBook Section 10.7. You should also have studied and experimented with the zyBook code in Section 10.7, so that you are familiar with the Graph, Vertex and Edge classes you will need as you develop the program for this submission. The other major thing you need to understand (and see below) is the format of the textfile containing the flight route information, since your program will need to be able to read its data from a file with this format.
  5. Prepare your my_tests.sh testing script.
  6. When everything is working correctly, make a final check before submission to ensure your source code is identified, formatted, and documented properly. And don't forget to complete the self-assessment comment of your submission.
  7. Finally, submit the required files by copying just those files into the submissions/s05 directory in your u## account.

Additional Notes, Requirements, Specifications and/or Hints (if any)

  1. Let's use the supplied sample input file flights_world.txt to explain the format of the flight route data. Here are the contents of this file (11 lines):
    
      4
      Tokyo
      New York
      London
      Sydney
      0 1 6743
      0 2 5941
      0 3 4863
      1 2 3425
      1 3 9868
      2 3 10562
    
    
    The first line of the file contains the integer 4, which indicates that this file contains information on flight routes between four citites, and those four cities are listed on the next four lines. We make the simplifying but entirely reasonable assumption that if there is a flight route from city A to city B, then there is also a corresponding flight route from city B to city A, and of course the number of miles is the same no matter in which direction you travel. The rest of the lines in the file give the distances between cities in the third column. The first two columns contain the "index" values for the cities, with (in this case) Tokyo at index 0, New York at index 1, London at index 2, and Sydney at index 3. With this in mind, we can see (for example) that the line 0 2 5941 tells us that the route from Tokyo to London (or from London to Tokyo) is 5941 miles, and the line 1 3 9868 tells us that the route from New York to Sydney (or from Sydney to New York) is 9868 miles. A file with more cities would be formatted in a similar manner.