Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            TicTacToe _TicTacToe = new TicTacToe();
            RandomAI  _RandomAI  = new RandomAI();
            ConsoleUI _ConsoleUI = new ConsoleUI(_TicTacToe, _RandomAI);

            _ConsoleUI.Play();
        }
Ejemplo n.º 2
0
        static void SelectPlayers(out IPlayer player1, out IPlayer player2, ref Board Board)
        {
            int    turn = 1, choice;
            string name;

            player1 = null;
            player2 = null;
            do
            {
                View.ClearScreen();
                View.SelectPlayer(turn);
                View.SelectPlayerMenu();
                choice = View.GetIntegerChoice();
                if (choice == 1 || choice == 2)
                {
                    View.ChooseName();
                    name = View.GetStringChoice();
                    if (turn == 1)
                    {
                        // This give a compilation error when using tertiary operator
                        // player1 = choice == 1 ? new RandomAI(name, ref Board, Field.Circle) : new Human(name, ref Board, Field.Circle);
                        // Type of conditional expression cannot be determined because
                        // there is no implicit conversion between 'TicTacToe.RandomAI' and 'TicTacToe.Human'
                        if (choice == 1)
                        {
                            player1 = new RandomAI(name, ref Board, Field.Circle);
                        }
                        else
                        {
                            player1 = new Human(name, ref Board, Field.Circle);
                        }
                    }
                    else
                    {
                        if (choice == 1)
                        {
                            player2 = new RandomAI(name, ref Board, Field.Cross);
                        }
                        else
                        {
                            player2 = new Human(name, ref Board, Field.Cross);
                        }
                    }
                    turn++;
                }
            } while (turn < 3);
        }