#include #include #include "WordCounterT.h" /* private: std::string word; int count{0}; */ using namespace std; WordCounterT::WordCounterT() {} string CleanString(string word) { string rv; for(size_t i =0; i < word.size(); ++i) { if (isalpha(word[i])) { rv = rv + static_cast(tolower(word[i])); } } return rv; } WordCounterT::WordCounterT(std::string newWord){ word = CleanString(newWord); if (word != "") { count = 1; } } std::string WordCounterT::GetWord() const{ return word; } int WordCounterT::GetCount() const{ return count; } bool WordCounterT::operator == (const WordCounterT & other) const{ return word == other.word; } WordCounterT & WordCounterT::operator ++(){ ++count; return *this; } WordCounterT WordCounterT::operator ++(int){ WordCounterT tmp{*this}; ++count; return tmp; } std::ostream & operator << (ostream & s, const WordCounterT & word){ s << word.GetWord() << ":" << word.GetCount(); return s; }