// You will edit and turn in this CPP file. // Also remove these comments here and add your own. // TODO remove this comment header and replace with your own #include #include #include #include #include "Boggle.h" #include "bogglemain.h" #include "strlib.h" #include /* * Plays one game of Boggle using the given boggle game state object. */ void playOneGame(Boggle& boggle) { boggle.clear(); bool input_custom_board = yesOrNo("Input custom board? "); if (input_custom_board) { string input_board; while (true) { cout << "Input your board (16 characters): "; getline(cin, input_board); if (input_board.length() == 16) { if (boggle.letters_from_string(input_board)) { break; } else { cout << "Please input a valid string" << endl; } } else { cout << "Please input 16 characters only" << endl; } } } else { boggle.shuffle(); } boggle.find_all_words(); cout << boggle.debug_words() << endl; std::cout << "It's your turn!" << std::endl; cout << boggle.board_to_string() << endl; string user_input; while (true) { cout << "Your words (" << boggle.get_user_words_size() << "):" << endl; cout << boggle.user_words_to_string() << endl; cout << "Your score: " << boggle.get_user_score() << endl; cout << "Type a word (or press Enter to end your turn) "; getline(cin, user_input); if (user_input == "") { break; } if (!boggle.word_is_valid(user_input)) { cout << "Your word is invalid" << endl; } else if (!boggle.word_is_unplayed(user_input)) { cout << "Your word has already been played!" << endl; } else if (user_input.length() < 4) { cout << "Your word is too short!" << endl; } else { cout << "You found a new word!" << endl; boggle.add_user_word(user_input); } } } /* * Erases all currently visible text from the output console. */ void clearConsole() { #if defined(_WIN32) || defined(_WIN64) std::system("CLS"); #else // assume POSIX std::system("clear"); #endif }