public static void Main() { TicTacToeGame newGame = new TicTacToeGame(); TicTacToeGame.eBoardCell firstPlayerSymbol = TicTacToeGame.eBoardCell.X, secondPlayerSymbol = TicTacToeGame.eBoardCell.O; TicTacToeGame.eBoardCell currentSymbol = firstPlayerSymbol; newGame.PrintBoard(); do { int xcoord; int ycoord; newGame.MakeMove(currentSymbol, out xcoord, out ycoord); Console.Clear(); newGame.PrintBoard(); newGame.IsWonGame(xcoord, ycoord); if (!newGame.IsGameOver) { if (currentSymbol == firstPlayerSymbol) { currentSymbol = secondPlayerSymbol; Console.WriteLine("second player now its your turn"); } else { currentSymbol = firstPlayerSymbol; Console.WriteLine("second player now its your turn"); } } }while (!newGame.IsGameOver); Console.WriteLine("The game over"); }
public void MakeMove(TicTacToeGame.eBoardCell i_PlayerSymbol, out int xcoord, out int ycoord) { bool validMove = true; do { Console.WriteLine("Please choose your x,y coordinates,"); bool checkXcoord = int.TryParse(Console.ReadLine(), out xcoord); bool checkYcoord = int.TryParse(Console.ReadLine(), out ycoord); if (checkXcoord && checkYcoord) { validMove = isLegalMove(xcoord, ycoord); if (!validMove) { Console.WriteLine("your move not valid please try again"); } } else { Console.WriteLine("your input is invalid"); } }while (!validMove); m_BoardGame[xcoord, ycoord] = i_PlayerSymbol; }