/****************************************************************/ /* Author: Dr. Spiegel */ /* Course: CIS237 */ /* Filename: app.cpp */ /* Purpose: This Example inputs a string and demon- */ /* strates how to store it using a subclass */ /* of an abstract base class that incorporates*/ /* virtual functions to enable polymorphism */ /* If a file name is */ /* input through the command line all of the */ /* options will be done automatically for the */ /* first line of the file */ /****************************************************************/ #include #include #include #include #include "WordList.h" #include "WordDataList.h" // #include "WordData.h" app only knows about the lists! using namespace std; void displayMenu(); /*********************************************************************/ /* Function Name: displayMenu() */ /* */ /* Description: Displays the menu on the screen. */ /*********************************************************************/ void printEverything(ifstream &inf,WordList *TheList); /*********************************************************************/ /* */ /* Function Name: printEverything */ /* */ /* Description: Takes in a sentence and sends it through every */ /* parsing and printing function */ /* */ /* Parameters: string sentence - sent to every function */ /* WordDataList TheList - The array of object */ /*********************************************************************/ int main(int argc,char *argv[]) { ifstream inf; WordList *TheList; if(argc>1) //if there was an input on the command line { inf.open(argv[1]); //try and open the file if (inf.fail()) //if the file does not open { //terminate cout<<"Sorry, the file failed to open."<parseIntoList(inf); // Apply polymorphism while (true) { displayMenu(); cin>>selection; switch(selection) { case '1': TheList->printIteratively(); break; case '2': TheList->printRecursively(); break; case '3': TheList->printPtr(); break; case '4': cout<<"Goodbye"<parseIntoList(inf); TheList->printIteratively(); TheList->printRecursively(); TheList->printPtr(); }