Add macro to have correct path on macOS

This commit is contained in:
Love 2024-09-11 17:44:51 +02:00
parent 0155caa48e
commit 6e5fa6778f
3 changed files with 13 additions and 6 deletions

View File

@ -12,9 +12,17 @@
#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 CUBE_SIDES = 6; // the number of sides on each cube
static string CUBES[NUM_CUBES] = { // the letters on all 6 sides of every cube
static std::string CUBES[NUM_CUBES] = { // the letters on all 6 sides of every cube
"AAEEGN", "ABBJOO", "ACHOPS", "AFFKPS", "AOOTTW", "CIMOTU",
"DEILRX", "DELRVY", "DISTTY", "EEGHNW", "EEINSU", "EHRTVW",
"EIOSST", "ELRTTY", "HIMNQU", "HLNNRZ"};

View File

@ -11,13 +11,10 @@
#include <iostream>
#include <string>
// TODO: include any other header files you need
using namespace std;
class Boggle {
public:
const string DICTIONARY_FILE = "EnglishWords.dat";
static const std::string DICTIONARY_FILE;
const int MIN_WORD_LENGTH = 4;
const int BOARD_SIZE = 4;
@ -27,4 +24,6 @@ private:
// TODO: decide the private member variables/functions and declare them
};
#endif

View File

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