#include #include #include #include #include "MyUtil.h" #include "ActionT.h" #include "WordT.h" #include "WordListT.h" using namespace std; string GetFileName(); string FixWord(string word); void PrintArray(WordListT words ); void ReadWords( WordListT & words); ActionT GetUserAction(); void PerformUserAction(ActionT action, bool & done); int main() { bool done{false}; ActionT action{ActionT::QUIT}; WordListT words; //WordListT copyOfWords; ReadWords(words); words.SortWords(); PrintArray(words); //copyOfWords = words; while (not done) { action = GetUserAction(); PerformUserAction(action, done); } return 0; } void PrintArray(WordListT words){ WordT tmp; words.FirstWord(); tmp = words.CurrentWord(); while (words.NextWord()) { cout << setw(20) << tmp.GetWord() << setw(4) << tmp.GetCount() << endl; tmp = words.CurrentWord(); } return; } string GetFileName() { string name; cout << "Enter the name of the input file: "; cin >> name; cout << endl; return name; } string FixWord(string word) { string fixedWord; fixedWord = Strip(word); fixedWord = MakeLower(fixedWord); return fixedWord; } void ReadWords( WordListT & words){ string fileName; ifstream inFile; string word; fileName = GetFileName(); inFile.open(fileName); if (inFile) { inFile >> word; while (inFile) { word = FixWord(word); if (word != "") { words.AddWord(word); } inFile >> word; } inFile.close(); } return; } ActionT GetUserAction(){ cout << "Getting the user action" << endl; return ActionT::QUIT; } void PerformUserAction(ActionT action, bool & done) { cout << "Performing the user action" << endl; done = action == ActionT::QUIT; return; }