summaryrefslogtreecommitdiffstats
path: root/labb5/src
diff options
context:
space:
mode:
Diffstat (limited to 'labb5/src')
-rwxr-xr-xlabb5/src/Boggle.h2
-rwxr-xr-xlabb5/src/boggleplay.cpp8
2 files changed, 6 insertions, 4 deletions
diff --git a/labb5/src/Boggle.h b/labb5/src/Boggle.h
index b134218..1c73f3d 100755
--- a/labb5/src/Boggle.h
+++ b/labb5/src/Boggle.h
@@ -37,6 +37,7 @@ public:
string board_to_string() const;
string user_words_to_string(int words_per_line = 8) const;
string computer_words_to_string(int words_per_line = 8) const;
+ string words_to_string(const set<string>& words, int words_per_line = 8) const;
void do_computer_turn();
int get_computer_words_size() const;
@@ -52,7 +53,6 @@ public:
private:
void find_all_words_helper(set<string>& words, point cur_point, string cur_word, set<point> visited) const;
bool find_single_word_helper(const string& word, point cur_point, string cur_word, set<point> visited) const;
- string words_to_string(const set<string>& words, int words_per_line) const;
Lexicon dictionary;
Grid<char> board;
diff --git a/labb5/src/boggleplay.cpp b/labb5/src/boggleplay.cpp
index 3bb1134..23daf99 100755
--- a/labb5/src/boggleplay.cpp
+++ b/labb5/src/boggleplay.cpp
@@ -42,9 +42,7 @@ void print_user_status(const Boggle& boggle) {
}
void ask_debug(Boggle& boggle) {
- if (yesOrNo("Enable debug mode? ")) {
- boggle.debug_mode = true;
- }
+ boggle.debug_mode = yesOrNo("Enable debug mode? ");
}
/*
@@ -54,12 +52,14 @@ void playOneGame(Boggle& boggle) {
boggle.clear();
setup_board(boggle);
ask_debug(boggle);
+ set<string> words_left = boggle.find_all_words();
clearConsole();
cout << endl; // this is later replaced by the response to the prev word
if (boggle.debug_mode) cout << endl; // debug mode means two lines
string user_input;
while (true) {
+ if (boggle.debug_mode) cout << boggle.words_to_string(words_left) << endl << endl;
cout << "It's your turn!" << endl;
print_user_status(boggle);
cout << "Type a word (or press Enter to end your turn) ";
@@ -77,8 +77,10 @@ void playOneGame(Boggle& boggle) {
} else {
cout << "You found a new word!" << endl;
boggle.add_user_word(user_input);
+ words_left.erase(user_input);
}
}
+ clearConsole();
print_user_status(boggle);
cout << endl;