Write a program that maintains certain data about airlines. It contains two kinds of data for each airline: 1. The name of the airline: a string which may contain blanks 2. Sets of airports that a passenger can travel among using only this airline. That is, for any two airports that belong to the same set, a passenger can travel from one to the other (possibly using some other airports in the same set). These sets are therefore a partitioning of the set of the airports that the airline can fly into and out of. Note that a set containing only one airport is possible. It would be an airport where the airline may eventually be able to fly into and out of, but at the moment, it has no flights to or from it. Each airport has the following data: code: a three letter code that uniquely identifies the airport name: a string that could contain blanks 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 airline with that name, then a new airline with that name is created. If there is no airport with that code, then a new airport with that code is created, and the program prompts the user for the name of the new airport. If the airline already exists and the airport is already a member of one of the sets belonging to the airline, then an error has occured. If the airport is not yet a member of one of the sets belonging to the airline, then it becomes the only member of a new set belonging to the airline. 2. Add Connection (AC) " " If and are valid airport codes that are members of different sets of the airline, then a new set is formed consisting of the union of the two sets, and the two old sets are removed. If the airports are already members of the same set, then a message to that effect should be generated. 3. List Airlines (LA) Displays all airlines and their airports, indicating which airports belong to the same set. How you do this is up to you, but it should be clear. 4. Check Connection (CC) If and are valid airport codes, then the program checks whether they are members of the same set belonging to the airline. If they are, then it outputs a message saying so. If there are no connections, then it should say so. 5. Quit (Q) The program ends.
Here's an example (user responses are shown in red):
Please enter a command: aa "USAir" ord
Airport's name = Orlando
Please enter a command: aa "USAir" lax
Airport's name = Los Angeles
Please enter a command: aa "USAir" lag
Airport's name = La Guardia
Please enter a command: ac "USAir" lax lag
Connection added between lax (Los Angeles) and
lag (La Guardia).
Please enter a command: la
LIST OF AIRLINES
Airports for USAir
CODE NAME BELONGS TO
lag La Guardia Set 2
lax Los Angeles Set 2
ord Orlando Set 1
Please enter a command: cc "USAir" lax ord
There are no connections between lax (Los Angeles)
and ord (Orlando).
Please enter a command: ac "USAir" lag ord
Connection added between lag (La Guardia) and
ord (Orlando).
Please enter a command: cc "USAir" lax ord
There are connections between lax (Los Angeles)
and ord (Orlando)
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 la or cc; in fact, you should be able to do better.
Turn in:
Within this individual directory, create a subdirectory named p3. Copy all your source files and the executable file p3 into your p3 directory, including header files, but no object files. So, for example, if your login name was smithjd then your files should be copied to /afs/cu/class/cs344jl/smithjd/p3. 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. Note: you can't compile and run your program in your /afs/cu/class/cs344jl/... directory. You can do it in your own polaris directory and then transfer the files to /afs/...