From 6e5fa6778fb418df21ed8993c1a94ce15aef5636 Mon Sep 17 00:00:00 2001 From: Love Billenius Date: Wed, 11 Sep 2024 17:44:51 +0200 Subject: [PATCH] Add macro to have correct path on macOS --- src/Boggle.cpp | 10 +++++++++- src/Boggle.h | 7 +++---- src/shuffle.h | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Boggle.cpp b/src/Boggle.cpp index 23f5aac..bdc34b5 100755 --- a/src/Boggle.cpp +++ b/src/Boggle.cpp @@ -12,9 +12,17 @@ #include "strlib.h" #include + +// 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"}; diff --git a/src/Boggle.h b/src/Boggle.h index 36a518e..43fdb03 100755 --- a/src/Boggle.h +++ b/src/Boggle.h @@ -11,13 +11,10 @@ #include #include -// 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 diff --git a/src/shuffle.h b/src/shuffle.h index ebf48c2..7d056ba 100755 --- a/src/shuffle.h +++ b/src/shuffle.h @@ -44,7 +44,7 @@ void shuffle(T** array2d, int rows, int cols) { } template -void shuffle(vector& v) { +void shuffle(std::vector& v) { for (int i = 0, length = v.size(); i < length; i++) { int j = randomInteger(i, length - 1); if (i != j) {