//------------------------------------------------------------------- // File :main.C // Author :Alicia Thorsen // Course :CS1129 // // Program implements the game of Boggle by generating a Boggle board // then asks the user to find as many words as possible on the baord. // The program locates all words on the board and checks the dictionary // to see if they are acceptable Boggle words. Each word is then // scored and a final score is displayed to the user. The game // also displays all valid words on the board which the user did not // find. //------------------------------------------------------------------- #include "board.h" #include "getWords.h" #include "search.h" #include "score.h" #include "dictionary.h" #include #include #include using namespace std; int main() { string *words, *dictionary, *answers; bool * found; char board[SIZE][SIZE]; int wordsCt = 0, dictSize = 0, ansSize = 0; string blank, response; bool done = false; //Seed random number generator srand(time(0)); system("clear"); //Show Boggle logo showLogo(); //Show game instructions showInstructions(); //Read in dictionary dictionary = loadDictionary(dictSize); while (!done) { cout << "\n>>> Press enter to play ..."; cout.flush(); //Read in board getBoard(board); //Find all valid words on boggle board answers = getSolution(board, dictionary, dictSize, ansSize); //Start game getline(cin, blank); system("clear"); //Initialize found array found = new bool[ansSize]; if (found == NULL) { cout << "Memory Allocation Error! Aborting!" << endl; exit(1); } for (int i = 0; i < ansSize; i++) found[i] = false; //Display board and get words from user words = getWords(board, wordsCt); //Verify words and display score scoreWords(board, words, wordsCt, answers, ansSize, found); //Find all words human player missed showMissedWords(answers, ansSize, found); delete [] words; delete [] answers; delete [] found; cout << "\nPlay again? (y/n) : "; getline(cin, response); if (tolower(response[0]) != 'y') done = true; } cout << endl; delete [] dictionary; return 0; }//end main()