Homework 4 (Boggle) FAQ

Q: How do I figure out what code goes in which file, the boggleplay.cpp vs. the Boggle.cpp/h?
A: Boggle.h/cpp should keep track of the data used in the game, such as the sixteen letter cubes, what words have been guessed, scores, the dictionary, and so on. Boggle.h/cpp should also contain all algorithms for searching for words on the board and all recursive code. The boggleplay.cpp file should contain user interface code to drive the game and all cin / cout console input/output statements. You should never put cout / getLine statements in Boggle.h/cpp. If you need to print some of the Boggle class's data, write a member function in Boggle to return the data to boggleplay and then have boggleplay print it.

When you are doing the GUI, you can put GUI/animation code in either file. Ideally most of it would be in boggleplay, but it is almost impossible to animate the word searching and recursive algorithms unless you put that part of the GUI interaction in Boggle.cpp.

Q: In my Boggle file I wrote a foo function. Now when I try to write foo(); in boggleplay, it doesn't work. Why not?
A: Remember that the functions in Boggle.h/cpp are member functions, functions inside of an object. So you need to get an object of type Boggle and call the function on it. For example:
void playOneGame(...) {
    ...
    Boggle myBoggle(...);
    ...
    myBoggle.foo();
}
Q: As is stated in the spec, the Boggle class itself should not contain any output statements to cout. Therefore, in order for boggleplay to output the current game board state, can we make the data inside Boggle be a public data member instead of private?
A: No, you should never make data members public. If you need access to data, provide an accessor function that returns some data, like a function that takes a row/column and returns the character at that location, etc.
Q: How do I implement the part where the user presses ENTER to end their turn?
A: The simplest way to avoid this problem is to always read input using getLine or getline, never with "cin >>". If the line is an empty string, that means the user just pressed Enter.
Q: How do I output the words that were found in alphabetical order?
A: Use a collection that just naturally stores them that way.
Q: What does this error mean?
error: invalid conversion from 'char' to 'const char*'
A: You are trying to use a char in place of a string. You can convert a char into a string if necessary by doing something like this:
char c = 'Q';
string s;
s += c;    // "Q"
or,
string s = string("") + c;
Q: Which Boggle member functions should be const?
A: All the ones that don't modify the state of the Boggle object. Honestly, if you are having trouble with this aspect of the assignment, you could try making every function const, then remove the modifier from the ones that fail to compile. Though it would be better for you to actually understand why a given member should / shouldn't be const.
Q: How efficient must my computer word search be? Mine takes up to a few minutes to run; is this okay?
A: It should finish running almost immediately. If your solution takes more than a few seconds to run, something is wrong and you should fix it if you want to receive full credit.
This document and its content are copyright © Marty Stepp, 2014. All rights reserved. Any redistribution, reproduction, transmission, or storage of part or all of the contents in any form is prohibited without the authors' expressed written permission.