Roll function
This commit is contained in:
parent
12dd509f20
commit
3a831b0099
@ -11,7 +11,7 @@
|
||||
#include "shuffle.h"
|
||||
#include "strlib.h"
|
||||
#include <sstream>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
// The res folder isn't copied the same way on macOS
|
||||
#ifdef __APPLE__
|
||||
@ -27,4 +27,22 @@ static std::string CUBES[NUM_CUBES] = { // the letters on all 6 sides of every c
|
||||
"DEILRX", "DELRVY", "DISTTY", "EEGHNW", "EEINSU", "EHRTVW",
|
||||
"EIOSST", "ELRTTY", "HIMNQU", "HLNNRZ"};
|
||||
|
||||
// TODO: implement the members you declared in Boggle.h
|
||||
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;
|
||||
std::copy(std::begin(CUBES), std::end(CUBES), cubes.begin());
|
||||
shuffle(cubes.data(), cubes.size());
|
||||
|
||||
// Just return the first NUM_ROLLED_CUBES (4pcs) entries
|
||||
std::array<std::string, NUM_ROLLED_CUBES> ret;
|
||||
std::copy(cubes.begin(), cubes.begin() + NUM_ROLLED_CUBES, ret.begin());
|
||||
return ret;
|
||||
}
|
||||
|
||||
Boggle::Boggle()
|
||||
: showingSides(rollSides()), englishWords(Boggle::DICTIONARY_FILE) {}
|
||||
|
||||
bool Boggle::insertWordIfValid() {
|
||||
|
||||
}
|
||||
|
12
src/Boggle.h
12
src/Boggle.h
@ -10,7 +10,9 @@
|
||||
#define _boggle_h
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "lexicon.h"
|
||||
|
||||
class Boggle {
|
||||
public:
|
||||
@ -18,10 +20,16 @@ public:
|
||||
const int MIN_WORD_LENGTH = 4;
|
||||
const int BOARD_SIZE = 4;
|
||||
|
||||
// TODO: decide the public member functions and declare them
|
||||
Boggle();
|
||||
|
||||
/**
|
||||
* @return true if the word read was valid, false if not
|
||||
*/
|
||||
bool insertWordIfValid();
|
||||
private:
|
||||
// TODO: decide the private member variables/functions and declare them
|
||||
std::vector<std::string> userWords;
|
||||
std::array<std::string, 4> showingSides;
|
||||
Lexicon englishWords;
|
||||
};
|
||||
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
* Plays one game of Boggle using the given boggle game state object.
|
||||
*/
|
||||
void playOneGame(Boggle& boggle) {
|
||||
// TODO: implement this function (and add any other functions you like to help you)
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user