diff --git a/src/Boggle.cpp b/src/Boggle.cpp index 8814215..54332ff 100755 --- a/src/Boggle.cpp +++ b/src/Boggle.cpp @@ -55,3 +55,9 @@ bool Boggle::isWordPlayed(const std::string &word) const { return std::find(m_playedWords.begin(), m_playedWords.end(), word) != m_playedWords.end(); } + +unsigned int Boggle::getPointsForWord(const std::string &word) { + // This is kept as a variable to avoid static_cast + const int pointsForValidWord = word.length() - s_MIN_WORD_LENGTH; + return std::min(pointsForValidWord, 0); +} diff --git a/src/Boggle.h b/src/Boggle.h index 632074b..07550dd 100755 --- a/src/Boggle.h +++ b/src/Boggle.h @@ -27,6 +27,7 @@ public: bool isWordEnglish(const std::string &word) const; bool isWordLongEnough(const std::string &word) const; bool isWordPlayed(const std::string &word) const; + static unsigned int getPointsForWord(const std::string &word); private: std::vector m_playedWords;