I'm struggling with validating the move so you can't put in the same move that's already put in. Also struggling with ending the loop when the game is over. I got everything else working please help me!
To start with I added a get function to the class. Then in main I changed the condition of the while loop to use this get function to check if the game is over. With a condition of (1) this is an endless loop with no way out.
In the class I initialized the last three private variables.
In the class .cpp file I commented out lines 8 and 9 along with changing line 236 to while (!gameOver);. I also commented out lines 151 - 154 of the "win" function because this code does nothing.
The program runs better except the last choice entered does not display before it tells you that someone wins. Also the line 231 in function "TicTacToe::main()" could be better written to show which player is making the choice. And in "TicTacToe::main()" move function "win" down to be the last function called and your board will display properly.
In the function "TicTacToe::view()" you might want to put a space between each variable to make the display easier to read.
sorry i'm rather new to using classes I don't fully know how to go about using the getfunction in a while loop any more tip is very appreciated here's what i have so far.
it says i cant' do !tictactoe.gameOver for obvious reason, i'm still learning about classes.
// ConsoleApplication3.cpp : Defines the entry point for the console application.
//
#include "TicTacToe.h"
#include <cstdlib>
#include <iostream>
usingnamespace std;
int main()
{
TicTacToe TicTacToe;
do
{
TicTacToe.main();
} while (!(TicTacToe.getGameOver));
system("PAUSE");
return 0;
}
"gameOver" is private member variable of the class, so only a public member function of the class can access the private member variables and functions of the class.
What is generally refereed to as a getter function would be: