Greetings, you may know me from my posting in the C Forums.
Having basic knowledge in Java, and thus a basic knowledge in Object Orientation, I decided to give C++ a go.
I decided to make a console-based tic-tac-toe game.
I'm having fun at it so far, but I have run up to a problem. I have a pointer to a Grid class (made by myself) called grid.
Whenever I call grid->isMoreMoves() , it seems to return true, as I am stuck in a loop dependent on it eventually becoming false.
I can't work out what I'm doing wrong? Any ideas?
Code:
//boxes (class field) is an array of 9 characters that represent each
//"box" of the grid.
//mark (class field) is an array of 2 characters" ( 'X' or 'O'), one for
//each player.
//This function is contained in the public section of the class.
bool isMoreMoves()
{
bool moreMoves = false;
for ( int i = 0; i < 9; i++)
{
if ( (boxes[i] != mark[0]) || (boxes[i] != mark[1]) )
{
moreMoves = true;
}
cout << boxes[i] << " "; //This line was to determine whether or not I was getting all values
}
cout << endl;
return moreMoves;
}
I'm testing out as only player 1, as I have not implemented switching players yet.