summaryrefslogtreecommitdiffstats
path: root/labb5/src/boggleplay.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'labb5/src/boggleplay.cpp')
-rwxr-xr-xlabb5/src/boggleplay.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/labb5/src/boggleplay.cpp b/labb5/src/boggleplay.cpp
index 60e45c6..b11c9d2 100755
--- a/labb5/src/boggleplay.cpp
+++ b/labb5/src/boggleplay.cpp
@@ -34,22 +34,28 @@ void setup_board(Boggle& boggle) {
}
}
+void print_user_status(const Boggle& boggle) {
+ cout << boggle.board_to_string() << endl;
+ cout << "Your words (" << boggle.get_user_words_size() << "): " << endl;
+ cout << boggle.user_words_to_string() << endl;
+ cout << "Your score: " << boggle.get_user_score() << endl;
+}
+
/*
* Plays one game of Boggle using the given boggle game state object.
*/
void playOneGame(Boggle& boggle) {
boggle.clear();
setup_board(boggle);
+ clearConsole();
string user_input;
while (true) {
- std::cout << "It's your turn!" << std::endl;
- cout << boggle.board_to_string() << endl;
- 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 << "It's your turn!" << endl;
+ print_user_status(boggle);
cout << "Type a word (or press Enter to end your turn) ";
getline(cin, user_input);
+ clearConsole();
if (user_input == "") {
break;
}
@@ -64,11 +70,16 @@ void playOneGame(Boggle& boggle) {
boggle.add_user_word(user_input);
}
}
+ print_user_status(boggle);
+ cout << endl;
+
cout << "It's my turn!" << endl;
boggle.do_computer_turn();
cout << "My words (" << boggle.get_computer_words_size() << "): " << endl;
cout << boggle.computer_words_to_string() << endl;
cout << "My score: " << boggle.get_computer_score() << endl;
+
+ cout << endl;
if (boggle.get_computer_score() > boggle.get_user_score()) {
cout << "Ha ha ha, I destroyed you. Better luck next time, puny human!" << endl;
} else {