#include "WordCountT.h" using namespace std; string Strip(string word) { string newWord; for(size_t i = 0; i < word.size(); ++i) { if (isalpha(word[i])) { newWord += static_cast(tolower(word[i])); } } return newWord; } WordCountT::WordCountT() { word = ""; count = 0; } WordCountT::WordCountT(string newWord){ word = Strip(newWord); count = 1; } bool WordCountT::operator ==(const WordCountT & other) const{ return word == other.word; } void WordCountT::Increment(size_t amount){ count += amount; } WordCountT WordCountT::operator + (const WordCountT & other) const{ WordCountT newWord; newWord.word = word; newWord.count = count + other.count; return newWord; } bool WordCountT::operator < (const WordCountT & other) const{ return word < other.word; } bool WordCountT::CountCompare(const WordCountT & other) const{ return count < other.count; } size_t WordCountT::Count() const{ return count; } string WordCountT::Word() const{ return word; } WordCountT & WordCountT::operator ++() { ++count; return *this; } WordCountT WordCountT::operator ++(int) { WordCountT other{*this}; ++count; return other; } ostream & operator << (std::ostream & s, const WordCountT & data){ s <<'"' << data.Word() << "\": " << data.Count(); return s; }