Compare commits

...

2 Commits

Author SHA1 Message Date
6e5fa6778f Add macro to have correct path on macOS 2024-09-11 17:44:51 +02:00
0155caa48e header 2024-09-11 17:36:05 +02:00
3 changed files with 32 additions and 24 deletions

View File

@ -1,22 +1,30 @@
// 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 "random.h"
#include "shuffle.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 CUBE_SIDES = 6; // the number of sides on each cube
static 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"
};
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"};
// 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
#define _boggle_h
#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;
// TODO: decide the public member functions and declare them
private:
// TODO: decide the private member variables/functions and declare them
// 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) {