points for word
This commit is contained in:
parent
6500a8f87f
commit
3a479e5cf1
@ -55,3 +55,9 @@ bool Boggle::isWordPlayed(const std::string &word) const {
|
|||||||
return std::find(m_playedWords.begin(), m_playedWords.end(), word) !=
|
return std::find(m_playedWords.begin(), m_playedWords.end(), word) !=
|
||||||
m_playedWords.end();
|
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);
|
||||||
|
}
|
||||||
|
@ -27,6 +27,7 @@ public:
|
|||||||
bool isWordEnglish(const std::string &word) const;
|
bool isWordEnglish(const std::string &word) const;
|
||||||
bool isWordLongEnough(const std::string &word) const;
|
bool isWordLongEnough(const std::string &word) const;
|
||||||
bool isWordPlayed(const std::string &word) const;
|
bool isWordPlayed(const std::string &word) const;
|
||||||
|
static unsigned int getPointsForWord(const std::string &word);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> m_playedWords;
|
std::vector<std::string> m_playedWords;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user