Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            int entry;

            do
            {
                TicTacToe ticTacToe = new TicTacToe();
                Console.WriteLine("Welcome to TicTacToeGame");
                bool turn = ticTacToe.CoinToss();

                char[] ticTacToeBoard = ticTacToe.CreateBoard();
                ticTacToe.playerSymbol = ticTacToe.ChooseSymbol();
                ticTacToe.ShowBoard();
                ticTacToe.StartGame(turn);

                Console.WriteLine("enter choice 1:Play another Game  2:no play");
                entry = Convert.ToInt32(Console.ReadLine());
            }while (entry == 1);
        }
Exemplo n.º 2
0
        public bool CoinToss()
        {
            bool      playerturn = false;
            TicTacToe t          = new TicTacToe();

            Console.WriteLine("Enter your choice for coin toss 0:Heads 1:tails");
            int    choice = Convert.ToInt32(Console.ReadLine());
            Random random = new Random();

            if (choice == random.Next(2))
            {
                Console.WriteLine("player won the toss and starts game");
                playerturn = true;

                return(playerturn);
            }
            else
            {
                Console.WriteLine(" computer starts game");
                return(playerturn);
            }
        }