From 4fcb511e0f4f81453b1c97df99c56ebe1b38aade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sun, 29 Nov 2020 03:52:46 +0100 Subject: function comments, reorder includes --- labb5/src/Boggle.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 4 deletions(-) (limited to 'labb5/src/Boggle.h') diff --git a/labb5/src/Boggle.h b/labb5/src/Boggle.h index 1c73f3d..8e923a9 100755 --- a/labb5/src/Boggle.h +++ b/labb5/src/Boggle.h @@ -8,11 +8,11 @@ #define _boggle_h #include -#include #include -#include "lexicon.h" -#include "grid.h" +#include #include +#include "grid.h" +#include "lexicon.h" using namespace std; using point = pair; @@ -25,20 +25,67 @@ public: bool debug_mode = false; Boggle(); + + /* + * Try to load a string of letters as the board. + * + * Returns wether it succeeds or not. + */ bool letters_from_string(const string& letters); void read_dictionary(); + + /* + * Clear state between games. + */ void clear(); + + /* + * Shuffle the board, both the dices and their locations. + */ void shuffle(); - set find_all_words() const; + /* + * Return wether a word can be constructed on the current board or not. + * + * Times itself if debug_mode is enabled. + */ bool find_single_word(const string& word) const; + /* + * Find and return all valid words that can be constructed from the current board. + * + * Times itself if debug_mode is enabled. + */ + set find_all_words() const; + + /* + * Convert a board to its string representation. + * + * Does not contain a trailing newline. + */ string board_to_string() const; + + /* + * Return a string represntation of all user words. + */ string user_words_to_string(int words_per_line = 8) const; + + /* + * Return a string represntation of all computer words. + */ string computer_words_to_string(int words_per_line = 8) const; + + /* + * Return a string representation of a set of words. + */ string words_to_string(const set& words, int words_per_line = 8) const; + /* + * Run calculations for when it's the computers turn. + * + * Finds which words the computer found and how many points they're worths. + */ void do_computer_turn(); int get_computer_words_size() const; int get_computer_score() const; @@ -48,6 +95,12 @@ public: bool word_is_valid(const string& word) const; bool word_is_unplayed(const string& word) const; + + /* + * Add a word the user has found and awards points. + * + * Does not do any checks. + */ void add_user_word(const string& word); private: -- cgit v1.2.1