points for word

This commit is contained in:
Love 2024-09-12 14:56:34 +02:00
parent 6500a8f87f
commit 3a479e5cf1
2 changed files with 7 additions and 0 deletions

View File

@ -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<int>
const int pointsForValidWord = word.length() - s_MIN_WORD_LENGTH;
return std::min(pointsForValidWord, 0);
}

View File

@ -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<std::string> m_playedWords;