Compare commits

..

No commits in common. "6e5fa6778fb418df21ed8993c1a94ce15aef5636" and "26bc06266e7187a2d170b5d09883d580ec2da35e" have entirely different histories.

3 changed files with 24 additions and 32 deletions

View File

@ -1,30 +1,22 @@
// ____ _ // This is the .cpp file you will edit and turn in.
// | __ ) ___ __ _ __ _| | ___ ___ _ __ _ __ // We have provided a minimal skeleton for you,
// | _ \ / _ \ / _` |/ _` | |/ _ \ / __| '_ \| '_ \ // but you must finish it as described in the spec.
// | |_) | (_) | (_| | (_| | | __/| (__| |_) | |_) | // Also remove these comments here and add your own.
// |____/ \___/ \__, |\__, |_|\___(_)___| .__/| .__/ // TODO: remove this comment header and replace it with your own
// |___/ |___/ |_| |_|
// Author: Love Billenius <lovbi127@student.liu.se>
#include <sstream>
#include "Boggle.h" #include "Boggle.h"
#include "random.h" #include "random.h"
#include "shuffle.h" #include "shuffle.h"
#include "strlib.h" #include "strlib.h"
#include <sstream>
// The res folder isn't copied the same way on macOS
#ifdef __APPLE__
const std::string Boggle::DICTIONARY_FILE = "../../../EnglishWords.dat";
#else
const std::string Boggle::DICTIONARY_FILE = "EnglishWords.dat";
#endif
static const int NUM_CUBES = 16; // the number of cubes in the game static const int NUM_CUBES = 16; // the number of cubes in the game
static const int CUBE_SIDES = 6; // the number of sides on each cube static const int CUBE_SIDES = 6; // the number of sides on each cube
static std::string CUBES[NUM_CUBES] = { // the letters on all 6 sides of every cube static string CUBES[NUM_CUBES] = { // the letters on all 6 sides of every cube
"AAEEGN", "ABBJOO", "ACHOPS", "AFFKPS", "AOOTTW", "CIMOTU", "AAEEGN", "ABBJOO", "ACHOPS", "AFFKPS",
"DEILRX", "DELRVY", "DISTTY", "EEGHNW", "EEINSU", "EHRTVW", "AOOTTW", "CIMOTU", "DEILRX", "DELRVY",
"EIOSST", "ELRTTY", "HIMNQU", "HLNNRZ"}; "DISTTY", "EEGHNW", "EEINSU", "EHRTVW",
"EIOSST", "ELRTTY", "HIMNQU", "HLNNRZ"
};
// TODO: implement the members you declared in Boggle.h // TODO: implement the members you declared in Boggle.h

View File

@ -1,29 +1,29 @@
// ____ _ _ // This is the .h file you will edit and turn in.
// | __ ) ___ __ _ __ _| | ___ | |__ // We have provided a minimal skeleton for you,
// | _ \ / _ \ / _` |/ _` | |/ _ \ | '_ \ // but you must finish it as described in the spec.
// | |_) | (_) | (_| | (_| | | __/_| | | | // Also remove these comments here and add your own, as well as on the members.
// |____/ \___/ \__, |\__, |_|\___(_)_| |_| // TODO: remove this comment header and replace it with your own
// |___/ |___/
// Author: Love Billenius <lovbi127@student.liu.se>
#ifndef _boggle_h #ifndef _boggle_h
#define _boggle_h #define _boggle_h
#include <iostream> #include <iostream>
#include <string> #include <string>
// TODO: include any other header files you need
using namespace std;
class Boggle { class Boggle {
public: public:
static const std::string DICTIONARY_FILE; const string DICTIONARY_FILE = "EnglishWords.dat";
const int MIN_WORD_LENGTH = 4; const int MIN_WORD_LENGTH = 4;
const int BOARD_SIZE = 4; const int BOARD_SIZE = 4;
// TODO: decide the public member functions and declare them // TODO: decide the public member functions and declare them
private: private:
// TODO: decide the private member variables/functions and declare them // TODO: decide the private member variables/functions and declare them
}; };
#endif #endif

View File

@ -44,7 +44,7 @@ void shuffle(T** array2d, int rows, int cols) {
} }
template <typename T> template <typename T>
void shuffle(std::vector<T>& v) { void shuffle(vector<T>& v) {
for (int i = 0, length = v.size(); i < length; i++) { for (int i = 0, length = v.size(); i < length; i++) {
int j = randomInteger(i, length - 1); int j = randomInteger(i, length - 1);
if (i != j) { if (i != j) {