From f3871a09e707f0771de14bb33d2111f768efa1de Mon Sep 17 00:00:00 2001 From: Love Billenius Date: Thu, 12 Sep 2024 14:41:16 +0200 Subject: [PATCH] Long enough --- src/Boggle.cpp | 9 ++++++--- src/Boggle.h | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Boggle.cpp b/src/Boggle.cpp index e21ecd2..4cc46bb 100755 --- a/src/Boggle.cpp +++ b/src/Boggle.cpp @@ -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 rollSides() { // Intermediate array to shuffle std::array cubes; @@ -44,11 +43,15 @@ std::array 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(); } diff --git a/src/Boggle.h b/src/Boggle.h index 36c98a8..cdab493 100755 --- a/src/Boggle.h +++ b/src/Boggle.h @@ -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 m_playedWords;