#include #include "WordCountT.h" using namespace std; void PrintAndTest(WordCountT word, string text, size_t count); void CompareWords(WordCountT word1, WordCountT word2); int main() { cout << endl; cout << "Making a blank word "<< endl; WordCountT word1; PrintAndTest(word1, "", 0); cout << endl << endl; cout << "Making a word from \"hello\"" << endl; WordCountT word2{"hello"}; PrintAndTest(word2,"hello", 1); cout << endl << endl; cout << "Incrementing " << word2 << " by 3" << endl; word2.Increment(3); PrintAndTest(word2, "hello", 4); cout << endl << endl; cout << "making a copy of " << word2 << endl; WordCountT word3{word2}; PrintAndTest(word3, "hello", 4); cout << endl << endl; word3.Increment(3); cout << "Adding " << word2 << " and " << word3 << endl; word2 = word2 + word3; PrintAndTest(word2, "hello", 11); cout << endl << endl; string testString{"123HeLl000O!"}; cout << "Testing with \"" << testString << '"' << endl; WordCountT word4(testString); PrintAndTest(word4, "hello", 1); cout << endl << endl; CompareWords(word2, word2); cout << endl; CompareWords(word2, word3); cout << endl; CompareWords(word3, word2); cout << endl; CompareWords(word2, word4); cout << endl; CompareWords(word4, word2); cout << endl; WordCountT word5{"bob"}; CompareWords(word5, word2); cout << endl; CompareWords(word2, word5); cout << endl; WordCountT word6{"zebra"}; word6.Increment(100); CompareWords(word6, word2); cout << endl; CompareWords(word2, word6); cout << endl; cout << endl; cout << "Testing ++ " << endl; cout << "\tword5 = word6" << endl; word5 = word6; cout << "\tword5 " << word5 << " word6 " << word6 << endl; cout << "\tword5 = ++word6; " << endl; word5 = ++word6; cout << "\tword5 " << word5 << " word6 " << word6 << endl; cout << "\tword5 = word6++;" << endl; word5 = word6++; cout << "\tword5 " << word5 << " word6 " << word6 << endl; cout << endl << endl; return 0; } void PrintAndTest(WordCountT word, string text, size_t count) { cout << "The word is " << word << endl; if (word.Word() != text or word.Count() != count) { cout << "Error: Improper value for this word." << endl; cout << "\tIt should be " << text << ": " << count << endl; } } void CompareWords(WordCountT word1, WordCountT word2){ cout << "Comparing " << word1 << " and " << word2 << endl; cout << "\tBy String: "; if(word1 == word2) { cout << "They are the same" << endl; } else if (word1 < word2) { cout << word1 << " is smaller." << endl; } else { cout << word2 << " is smaller." << endl; } cout << "\tBy Count: "; if (word1.CountCompare(word2) ) { cout << word1 << " is smaller or equal." << endl; } else { cout << word2 << " is smaller." << endl; } }