예제 #1
0
        private void button_Click(object sender, EventArgs e)
        {
            Button ingedrukt = sender as Button;

            if (t.ChooseCell(Int32.Parse(ingedrukt.Text)))
            {
                if (t.Status == TicTacToeEngine.GameStatus.PlayerOPlays)
                {
                    ingedrukt.Text = "X";
                }
                else if (t.Status == TicTacToeEngine.GameStatus.PlayerXPlays)
                {
                    ingedrukt.Text = "O";
                }
            }

            if (t.Status == TicTacToeEngine.GameStatus.PlayerOWins ||
                t.Status == TicTacToeEngine.GameStatus.PlayerXWins)
            {
                MessageBox.Show(t.Status.ToString());
            }
            else if (t.Status == TicTacToeEngine.GameStatus.Equal)
            {
                MessageBox.Show("Er is geen winnaar.");
            }
        }
예제 #2
0
        private static void Main(string[] args)
        {
            TicTacToeEngine t = new TicTacToeEngine();

            Console.WriteLine(t.Board());

            String input = Console.ReadLine();

            while (input != "exit")
            {
                if (input != "reset")
                {
                    int value;
                    if (int.TryParse(input, out value))
                    {
                        if (t.ChooseCell(value))
                        {
                            t.AssignCell(value);
                            t.CheckWinner();
                            Console.WriteLine(t.Board());
                        }

                        input = Console.ReadLine();
                    }
                }
                else
                {
                    t.reset();
                    Console.WriteLine(t.Board());
                    input = Console.ReadLine();
                }
            }
        }