Question
The entire menu and interface is already set up in the base code, so you just need to write the classes and functions. The BaseCode
The entire menu and interface is already set up in the base code, so you just need to write the classes and functions. The BaseCode is provided in the following link, or at the end of this question in text. https://www.cs.uic.edu/pub/CS211/ProjectS18/proj6Base.cpp TEST CASES: -Simple Data Files (no embedded f commands) https://www.cs.uic.edu/pub/CS211/ProjectS18/proj6data1.txt https://www.cs.uic.edu/pub/CS211/ProjectS18/proj6data6.txt https://www.cs.uic.edu/pub/CS211/ProjectS18/proj6data7.txt https://www.cs.uic.edu/pub/CS211/ProjectS18/proj6data8.txt -Complex Data Files (with embedded f commands) https://www.cs.uic.edu/pub/CS211/ProjectS18/proj6data2.txt https://www.cs.uic.edu/pub/CS211/ProjectS18/proj6data3.txt -Complex Data Files (with embedded and recursive f commands) https://www.cs.uic.edu/pub/CS211/ProjectS18/proj6data4.txt https://www.cs.uic.edu/pub/CS211/ProjectS18/proj6data5.txt -A "simple" data file with 45 nodes https://www.cs.uic.edu/pub/CS211/ProjectS18/proj6data9.txt
Base Code: // proj6Base.cpp
#include
class TravelNetwork { private: // Create the Data Members for the Travel Network here public: // Use a constructor to initialize the Data Members for Travel Network TravelNetwork() { } // The main loop for reading in input void processCommandLoop (FILE* inFile) { char buffer[300]; char* input;
input = fgets ( buffer, 300, inFile ); // get a line of input // loop until all lines are read from the input while (input != NULL) { // process each line of input using the strtok functions char* command; command = strtok (input , " \t");
printf ("*%s* ", command); if ( command == NULL ) printf ("Blank Line "); else if ( strcmp (command, "q") == 0) exit(1); else if ( strcmp (command, "?") == 0) showCommands(); else if ( strcmp (command, "t") == 0) doTravel(); else if ( strcmp (command, "r") == 0) doResize();
else if ( strcmp (command, "i") == 0) doInsert();
else if ( strcmp (command, "d") == 0) doDelete();
else if ( strcmp (command, "l") == 0) doList();
else if ( strcmp (command, "f") == 0) doFile();
else if ( strcmp (command, "#") == 0) ; else printf ("Command is not known: %s ", command); input = fgets ( buffer, 300, inFile ); // get the next line of input
} } void showCommands() { printf ("The commands for this project are: "); printf (" q "); printf (" ? "); printf (" # "); printf (" t
// get an integer value from the input char* next = strtok (NULL, " \t"); if ( next == NULL ) { printf ("Integer value expected "); return; } val1 = atoi ( next ); if ( val1 == 0 && strcmp (next, "0") != 0) { printf ("Integer value expected "); return; } // get another integer value from the input next = strtok (NULL, " \t"); if ( next == NULL ) { printf ("Integer value expected "); return; } val2 = atoi ( next ); if ( val2 == 0 && strcmp (next, "0") != 0) { printf ("Integer value expected "); return; } printf ("Performing the Travel Command from %d to %d ", val1, val2); } void doResize() { int val1 = 0; printf ("Performing the Resize Command with %d ", val1 );
} void doInsert() {
} void doDelete() {
} void doList() { } void doFile() { // get a filename from the input char* fname = strtok (NULL, " \t"); if ( fname == NULL ) { printf ("Filename expected "); return; } printf ("Performing the File command with file: %s ", fname); // next steps: (if any step fails: print an error message and return ) // 1. verify the file name is not currently in use // 2. open the file using fopen creating a new instance of FILE* // 3. recursively call processCommandLoop() with this new instance of FILE* as the parameter // 4. close the file when processCommandLoop() returns } };
int main (int argc, char** argv) { // set up the variable inFile to read from standard input FILE* inFile = stdin;
// set up the data needed for the airport adjcency list TravelNetwork airportData; // call the method that reads and parses the input airportData.processCommandLoop (inFile); printf ("Goodbye "); return 1; }
Can I Get There from Here? For this program, you will write a C++ Program to represent a travel network. This travel network will use an array of linked lists as its primary storage structure. This type of storage structure is typically called an "adiacency list" Please note: this write-up was originally taken from a non-C++ assignment. Any reference to non-C++ items were not properly "translated" into C++. Such items should use their C++ counterparts Assume you have a small airline that flies planes between a small number of airports. Each airport will be given a number. If a plane flies from airport X to airport Y, the network will have an "edge" from X to Y. Below are a number of drawings that could represent this idea. The airports are represented by the circled numbers, the edges are represented by the arrows. Consider the first drawing. It has 6 airports. It has a plane that flies from airport 1 to airport 2. Three planes fly from airport 2, one to airport 3, one to airport 4 and one to airport 5. No planes leave from airport 3 or from airport 5 (yes, it would be stupid to strand planes at those airports, but ignore that fact for now). Planes fly from airport 4 to airports 5 and 6. Finally, planes fly from airport 6 to airport 3 13 4 10 15 14 6 In an adjacency list, each location/airport needs a list of those locations/airports that one can get to in one move/flight. In this program, we need a list for each airport. If the travel network has N airports, the array will have N linked lists, one for each airport. If airport X has planes flying to 3 different airports, the linked list for airport X would have 3 nodes. Consider the following image showing a travel network and an adjacency list: 314 Can I Get There from Here? For this program, you will write a C++ Program to represent a travel network. This travel network will use an array of linked lists as its primary storage structure. This type of storage structure is typically called an "adiacency list" Please note: this write-up was originally taken from a non-C++ assignment. Any reference to non-C++ items were not properly "translated" into C++. Such items should use their C++ counterparts Assume you have a small airline that flies planes between a small number of airports. Each airport will be given a number. If a plane flies from airport X to airport Y, the network will have an "edge" from X to Y. Below are a number of drawings that could represent this idea. The airports are represented by the circled numbers, the edges are represented by the arrows. Consider the first drawing. It has 6 airports. It has a plane that flies from airport 1 to airport 2. Three planes fly from airport 2, one to airport 3, one to airport 4 and one to airport 5. No planes leave from airport 3 or from airport 5 (yes, it would be stupid to strand planes at those airports, but ignore that fact for now). Planes fly from airport 4 to airports 5 and 6. Finally, planes fly from airport 6 to airport 3 13 4 10 15 14 6 In an adjacency list, each location/airport needs a list of those locations/airports that one can get to in one move/flight. In this program, we need a list for each airport. If the travel network has N airports, the array will have N linked lists, one for each airport. If airport X has planes flying to 3 different airports, the linked list for airport X would have 3 nodes. Consider the following image showing a travel network and an adjacency list: 314Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started