Write a program that maintains the data about an airline's routes. It contains information about airports and connections between airports. Each airport has the following data: code: a three letter code that uniquely identifies the airport name: a string that could contain blanks capacity: a positive integer giving the maximum number of flights that the airport could handle in one day Each connection is specified by the airport that it departs from and the airport it arrives at, and it has the following data: distance: a positive real number giving the distance between the two airports This data can be updated with the following commands. Each command has a two letter abbreviation (upper or lower case), which is indicated in parentheses after its name. Some commands also have arguments shown in angle brackets (<>). 1. Add Airport (AA) If there is no airport with that, then a new airport with that code is added, and the program prompts the user for the name and capacity of the new airport. 2. Delete Airport (DA)The program finds the airport with that code, and displays that airport's data, followed by a message asking if the user wants to delete that airport. The user responds yes or no. If the response was yes, then that airport is removed, and all connections going to or from that airport are removed. 3. Add Connection (AC)If and are valid airport codes with no connection from the first to the second, and is a valid distance, then a connection with that distance is added between and . Note that existence of a connection from to does not imply there is a connection in the opposite direction, or even if there is, that the distances must be the same. 4. Delete Connection (DC) If and are valid airport codes, the program displays the data for that connection (codes and airport names for the two airports, and the distance between them), and asks if the user wants to delete that connection. The user responds yes or no. If the response was yes, then that connection is removed. 5. List Airports (LA) Displays all airports and their associated data, and for each airport, it shows all connections departing from that airport (destination and distance). 6. Find Path (FP) Finds the shortest path from to (if it exists). Displays the path by listing each airport code in the path from to , and the total distance. 7. Quit (Q) The program ends.
Here's an example (user responses are shown in red):
Please enter a command: aa ord Airport's name = Orlando Capacity = 350 Please enter a command: aa lax Airport's name = Los Angeles Capacity = 700 Please enter a command: aa lag Airport's name = La Guardia Capacity = 590 Please enter a command: ac lax lag 3000.8 Please enter a command: ac lag ord 2100.2 Please enter a command: ac lax ord 3100.45 Please enter a command: fp lax ord The shortest path from lax to ord is: lax ord Total distance = 3100.45 Please enter a command: dc lax ord Departure: lax Los Angeles Destination: ord Orlando Distance: 3100.45 miles Do you wish to delete this connection? yes Please enter a command: fp lax ord The shortest path from lax to ord is: lax lag ord Total distance = 5101.0 miles Please enter a command:q
Use the command and data prompts as shown above. You don't have to use the same formats for the outputs of commands like fp; in fact, you should be able to do better.
template class Graph { public: virtual bool addVertex(const Key&, const Elem&) = 0; virtual bool findVertex(const Key&, Elem&) = 0; virtual bool delVertex(const Key&) = 0; virtual bool addEdge(const Key&, const Key&, const Weight&) = 0; virtual bool isEdge(const Key&, const Key&, Elem&, Elem&, Weight&) = 0; virtual bool delEdge(const Key&, const Key&) = 0; }
The template should work for directed graphs with vertices of type Elem and keys of type Key, and edges with weights of type Weight.
Within this individual directory, create a subdirectory named p4. Copy all your source files and the executable file p4 into your p4 directory, including header files, but no object or executable files. So, for example, if your login name was smithjd then your source files should be copied to /afs/cu/class/cs344jl/smithjd/p4. These directories have permissions set so that no one other than yourself and Prof. Lynch can read the files. You may, of course, use whatever operating system and compiler you wish to develop your code, but the version you turn in, both hardcopy and the files submitted to AFS, must compile with g++ and run under polaris.