Esempio n. 1
0
        static void Main(string[] args)
        {
            while (true)
            {
                //Create object of the TicTacToe class
                TicTacToe ticTacToe = new TicTacToe();

                //Created new board
                char[] gameBoard = ticTacToe.CreateTicTacToeBoard();

                TicTacToe.Player player = ticTacToe.Toss();

                //Game continue after toss
                if (player == TicTacToe.Player.USER)
                {
                    ticTacToe.UserMovesFirst(gameBoard);
                }
                else if (player == TicTacToe.Player.CPU)
                {
                    ticTacToe.CpuMovesFirst(gameBoard);
                }
                bool playAgain = ticTacToe.PlayAgain();
                if (playAgain == false)
                {
                    break;
                }
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var t = new TicTacToe();

            char[] board  = t.CreateBoard();
            char   letter = t.ChooseLetter();

            t.Toss();
            t.Play();
            Console.WriteLine("\nCheck if won : " + t.CheckWinner(letter));
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Tic Tac Toe Game");
            TicTacToe tic = new TicTacToe();

            // To create a new board
            char [] board = tic.CreateBoard();
            // To show board
            tic.ShowBoard(board);
            tic.Toss();
            // To choose a letter by a user
            char userLetter     = tic.ChooseLetter();
            char computerLetter = (userLetter == 'X') ? 'O' : 'X';
            // To move desired location
            int userMove = tic.getUserMove(board);

            tic.makeMove(board, userMove, userLetter);
            tic.ShowBoard(board);
            //Computer Move
            int computerMove = tic.getComputerMove(board, computerLetter, userLetter);

            Console.WriteLine("Check if Won: " + tic.isWinner(board, userLetter));
        }