diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2020-11-29 03:12:49 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2020-11-29 03:12:49 +0100 |
| commit | f3a2c9fbc1c946379acdd077c0d742a3298a56e3 (patch) | |
| tree | 5ec921049e7ed7cd115e94a57d4dea3ee3d7d6fa /labb5/src/boggleplay.cpp | |
| parent | 34d24825172e89a973e2a3559fb112cb0d4b75e1 (diff) | |
| download | tddd86-f3a2c9fbc1c946379acdd077c0d742a3298a56e3.tar.gz | |
newline polish
Diffstat (limited to 'labb5/src/boggleplay.cpp')
| -rwxr-xr-x | labb5/src/boggleplay.cpp | 21 |
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 { |
