F
foolsmart2005
The idea of the game is for one player (the code-breaker) to guess the
secret code chosen by the
other player (the code-maker). The code is a sequence of n colored
pegs chosen from m available
colors. The code-breaker makes a series of pattern guesses. After each
guess, the code-maker
gives feedback in the form of two numbers: the number of pegs that are
of the right color and in
the correct position (represented by small black pegs), and the number
of pegs that are of the
correct color but in a wrong position (represented by small white
pegs).
Complete the class CodeMaker, and construct a simple driver to test
your logic in checkBlack
and checkWhite functions.
class CodeMaker
{
public:
// add in relevant Big 3 and supporting functions
unsigned int checkBlack (char guess[]) const; // same position same
color
unsigned int checkWhite (char guess[]) const; // same color different
position
private:
unsigned int color; // total number of colors (m)
unsigned int length; // length of secret code (n)
char *secret; // secret code, supports duplicate colors
};
I don't quite understand what the code for
unsigned int checkBlack (char guess[]) const; // same position same
color
unsigned int checkWhite (char guess[]) const; // same color different
position
want me to do. Could anyone give details to me?
I have written the Big3 and some supporting functions. Thanks!
secret code chosen by the
other player (the code-maker). The code is a sequence of n colored
pegs chosen from m available
colors. The code-breaker makes a series of pattern guesses. After each
guess, the code-maker
gives feedback in the form of two numbers: the number of pegs that are
of the right color and in
the correct position (represented by small black pegs), and the number
of pegs that are of the
correct color but in a wrong position (represented by small white
pegs).
Complete the class CodeMaker, and construct a simple driver to test
your logic in checkBlack
and checkWhite functions.
class CodeMaker
{
public:
// add in relevant Big 3 and supporting functions
unsigned int checkBlack (char guess[]) const; // same position same
color
unsigned int checkWhite (char guess[]) const; // same color different
position
private:
unsigned int color; // total number of colors (m)
unsigned int length; // length of secret code (n)
char *secret; // secret code, supports duplicate colors
};
I don't quite understand what the code for
unsigned int checkBlack (char guess[]) const; // same position same
color
unsigned int checkWhite (char guess[]) const; // same color different
position
want me to do. Could anyone give details to me?
I have written the Big3 and some supporting functions. Thanks!