Long enough

This commit is contained in:
Love 2024-09-12 14:41:16 +02:00
parent 92b62a9990
commit 9bb0e8823c
2 changed files with 8 additions and 4 deletions

View File

@ -28,7 +28,6 @@ static std::string CUBES[NUM_CUBES] =
"DEILRX", "DELRVY", "DISTTY", "EEGHNW", "EEINSU", "EHRTVW",
"EIOSST", "ELRTTY", "HIMNQU", "HLNNRZ"};
static const int NUM_ROLLED_CUBES = 4;
std::array<std::string, NUM_ROLLED_CUBES> rollSides() {
// Intermediate array to shuffle
std::array<std::string, NUM_CUBES> cubes;
@ -44,11 +43,15 @@ std::array<std::string, NUM_ROLLED_CUBES> rollSides() {
Boggle::Boggle()
: m_showingSides(rollSides()), m_englishWords(Boggle::DICTIONARY_FILE) {}
bool Boggle::isWordValid(const std::string &word) const {
bool Boggle::isWordEnglish(const std::string &word) const {
return m_englishWords.contains(word);
}
bool Boggle::isWordPlayed(const string &word) const {
bool Boggle::isWordLongEnough(const std::string &word) const {
return word.length() >= MIN_WORD_LENGTH;
}
bool Boggle::isWordPlayed(const std::string &word) const {
return std::find(m_playedWords.begin(), m_playedWords.end(), word) !=
m_playedWords.end();
}

View File

@ -25,7 +25,8 @@ public:
Boggle();
bool isWordValid(const std::string &word) const;
bool isWordEnglish(const std::string &word) const;
bool isWordLongEnough(const std::string &word) const;
bool isWordPlayed(const std::string &word) const;
private:
std::vector<std::string> m_playedWords;