Long enough
This commit is contained in:
parent
92b62a9990
commit
9bb0e8823c
@ -28,7 +28,6 @@ static std::string CUBES[NUM_CUBES] =
|
|||||||
"DEILRX", "DELRVY", "DISTTY", "EEGHNW", "EEINSU", "EHRTVW",
|
"DEILRX", "DELRVY", "DISTTY", "EEGHNW", "EEINSU", "EHRTVW",
|
||||||
"EIOSST", "ELRTTY", "HIMNQU", "HLNNRZ"};
|
"EIOSST", "ELRTTY", "HIMNQU", "HLNNRZ"};
|
||||||
|
|
||||||
static const int NUM_ROLLED_CUBES = 4;
|
|
||||||
std::array<std::string, NUM_ROLLED_CUBES> rollSides() {
|
std::array<std::string, NUM_ROLLED_CUBES> rollSides() {
|
||||||
// Intermediate array to shuffle
|
// Intermediate array to shuffle
|
||||||
std::array<std::string, NUM_CUBES> cubes;
|
std::array<std::string, NUM_CUBES> cubes;
|
||||||
@ -44,11 +43,15 @@ std::array<std::string, NUM_ROLLED_CUBES> rollSides() {
|
|||||||
Boggle::Boggle()
|
Boggle::Boggle()
|
||||||
: m_showingSides(rollSides()), m_englishWords(Boggle::DICTIONARY_FILE) {}
|
: 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);
|
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) !=
|
return std::find(m_playedWords.begin(), m_playedWords.end(), word) !=
|
||||||
m_playedWords.end();
|
m_playedWords.end();
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,8 @@ public:
|
|||||||
|
|
||||||
Boggle();
|
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;
|
bool isWordPlayed(const std::string &word) const;
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> m_playedWords;
|
std::vector<std::string> m_playedWords;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user