int main() { BogglePlayer player; string custom1[]={"T","o","T"}; string custom2[]={"a","b","c"}; string custom3[]={"s","c","e"}; string** custom4; custom4 = new string*[3]; for(unsigned int r=0; r<3;r++) { custom4[r] = new string[3]; } for(int j = 0; j < 3; j++) { custom4[0][j] = custom1[j]; custom4[1][j] = custom2[j]; custom4[2][j] = custom3[j]; } player.setBoard(3,3,custom4); vector<int> test; test = player.isOnBoard("BCE"); while(!test.empty()){ cout << test.back() << endl; test.pop_back(); } string tester = "TEST"; cout << tester.substr(1); //for(int i = 0; i < 3; i++) { //for(int j = 0; j < 3; j++) { //cout << custom4[i][j] << " "; //} //cout << "/n"; //} //} const set<string>& listwords = "hello"; player.buildLexicon(listwords); }
int main(){ //BogglePlayer boggle; /* BaseBogglePlayer * p = new BogglePlayer(); set<string> lex; string wordA("a"); string wordX("x"); lex.insert(wordA); lex.insert("z"); string row0[] = {"D","C"}; string row1[] = {"b","A"}; string* board[] = {row0,row1}; set<string> words; vector<int> locations; p->buildLexicon(lex); p->setBoard(2,2,board); */ BogglePlayer * boggle = new BogglePlayer(); //string row0[] = {"b","pp","l"}; string row0[] = {"le","g","e"}; //string row1[] = {"i","e","a"}; string row1[] = {"i","boa","bog"}; //string row2[] = {"r","e","p"}; string row2[] = {"r","d","j"}; //string** diceArray ={{"b","p","l"},{"i","q","a"},{"r","e","p"}}; string* diceArray[] = {row0, row1, row2}; boggle->setBoard(3, 3, diceArray); std::vector<int> result = boggle->isOnBoard("boggleboard"); if(result.empty()) cout << "empty vector" << endl; else { for(int i = 0; i < result.size(); i++) cout << "result is " << result[i] << endl; } return 0; }
void testChkpt(){ BogglePlayer bp; string **board; board = new string*[4]; for (size_t i=0;i<4;i++) board[i] = new string[4]; // Initialize board cout << "*** TESTING CHECKPOINT ( isOnBoard() and setBoard() ) ***" << endl; cout << "Initializing board..." << endl; cout << " s t h r " << endl; cout << " qu a v i " << endl; cout << " a t d j " << endl; cout << " c p n e " << endl << endl; board[0][0] = "s"; board[0][1] = "t"; board[0][2] = "h"; board[0][3] = "r"; board[1][0] = "qu"; board[1][1] = "a"; board[1][2] = "v"; board[1][3] = "i"; board[2][0] = "a"; board[2][1] = "t"; board[2][2] = "d"; board[2][3] = "j"; board[3][0] = "c"; board[3][1] = "p"; board[3][2] = "n"; board[3][3] = "e"; bp.setBoard(4,4,board); // Check for words. auto checkWord = [&bp](const string& word, bool should_be_found){ cout << "Checking for word \"" << word << "\"... "; vector<int> path = bp.isOnBoard(word); // If vector comes up empty if(path.size() == 0){ if(should_be_found == true) cerr << endl << "ERROR: \"" << word << "\" should be found on board." << endl; else cout << "[NOT FOUND]" << endl; } // If vector does not come up empty. else{ if(should_be_found == false) cerr << endl << "ERROR: \"" << word << "\" should not be found on board." << endl; else{ cout << "[FOUND]" << endl; cout << "Path to find \"" << word << "\" is: "; for(int coor: path){ cout << "(" << coor << ") "; } cout << endl; } } }; // Words that exist checkWord("qua", true); checkWord("tsadi", true); checkWord("stat", true); checkWord("hadj", true); checkWord("asquat", true); checkWord("aqua", true); // Words that don't exist. checkWord("staqus", false); checkWord("tdnptat", false); checkWord("asdfghjkl", false); checkWord("pad", false); checkWord("vvvvvvvv", false); cout << "Cleaning up test..."; for (size_t i=0;i<4;i++) delete[] board[i]; delete[] board; cout << "[DONE]" << endl << endl; }