From f3a2c9fbc1c946379acdd077c0d742a3298a56e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sun, 29 Nov 2020 03:12:49 +0100 Subject: newline polish --- labb5/src/boggleplay.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'labb5/src/boggleplay.cpp') 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 { -- cgit v1.2.1