Here is the main file, where I define the object game.
Game is using the function GetMove(), to make the move on the board, but this does not happen (why?).
game.DrawBoard(), displays the matrix fine.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
#include "TicTacToe.h"
usingnamespace std;
int main()
{
TicTacToe game;
char player = 'X';
game.GetMove(player);
game.DrawBoard();
game.TogglePlayer(player);
system("pause");
}
1. the = operator is assigning 1 to move. You probably want equality test ==.
2. If you do change it it do ==, you're still gonna get errors because move is uninitialized, it will contain some random junk value.
I corrected the problem, don't know how I missed that but anyway:
1 2 3 4 5 6 7 8 9 10 11
void TicTacToe::GetMove(char player)
{
int move;
cout <<"Enter the number of the field you would like to move:\n";
cin >> move;
if( move == 1)
{
board[0][0] = player;
}
. . .