Esempio n. 1
0
File: Program.cs Progetto: QTPx/spil
        private void Run()
        {
            Console.WriteLine("Vælg spil");
            Console.WriteLine("1. TicTacToe");
            Console.WriteLine("2. Sænke Slagskibe");
            string choise = Console.ReadLine();

            if (choise == "1")
            {
                TicTacToeMainMenu ticTacToeMainMenu = new TicTacToeMainMenu();
                ticTacToeMainMenu.Show();
            }
            if (choise == "2")
            {
                BattleShipMenu battleShipMenu = new BattleShipMenu();
                battleShipMenu.show();
            }
        }
Esempio n. 2
0
        public void Validate()
        {
            for (int i = 0; i < 3; i++)
            {
                char TestVinder1 = ' ';
                char TestVinder2 = ' ';
                void SlutValg()


                {
                    Console.WriteLine("Der er en vinder - vælg '1' for nyt spil eller '2' for Hovedmenu");
                    string NewInput = Console.ReadLine();


                    if (NewInput == "1")
                    {
                        GameBoard = new char[3, 3] {
                            { ' ', ' ', ' ' },
                            { ' ', ' ', ' ' },
                            { ' ', ' ', ' ' }
                        };
                    }
                    else if (NewInput == "2")
                    {
                        TicTacToeMainMenu ticTacToeMainMenu = new TicTacToeMainMenu();
                        ticTacToeMainMenu.Show();
                    }
                }

                TestVinder1 = GameBoard[i, 0];
                TestVinder2 = GameBoard[0, i];
                if (TestVinder1 == 'x' || TestVinder1 == 'o')
                {
                    if (GameBoard[i, 0] == GameBoard[i, 1] && GameBoard[i, 0] == GameBoard[i, 2])
                    {
                        SlutValg();
                    }
                }
                else if (TestVinder2 == 'x' || TestVinder2 == 'o')
                {
                    if (GameBoard[0, i] == GameBoard[1, i] && GameBoard[0, i] == GameBoard[2, i])
                    {
                        SlutValg();
                    }
                }
                else if (GameBoard[1, 1] == 'x' || GameBoard[1, 1] == 'o')
                {
                    if (GameBoard[0, 0] == GameBoard[1, 1] && GameBoard[1, 1] == GameBoard[2, 2])
                    {
                        SlutValg();
                    }
                    else if (GameBoard[0, 2] == GameBoard [1, 1] && GameBoard[2, 0] == GameBoard[1, 1])
                    {
                        SlutValg();
                    }
                }
            }
            if (playerNr == 1)
            {
                playerNr = 2;
            }
            else
            {
                playerNr = 1;
            }
        }