static void Main(string[] args)
        {
            WelcomeMesage();

            PlayerModel activePlayer = CreatePlayer("Player 1");
            PlayerModel opponent     = CreatePlayer("Player 2");
            PlayerModel winner       = null;

            do
            {
                DisplayShotGrid(activePlayer);

                RecordPlayerShot(activePlayer, opponent);

                bool doesGamecontinue = GameLogic.PlayerStillActive(opponent);

                if (doesGamecontinue == true)
                {
                    //swap players
                    (activePlayer, opponent) = (opponent, activePlayer);
                }
                else
                {
                    winner = activePlayer;
                }
            } while (winner == null);

            IdentifyWinner(winner);

            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            WelcomeMessage();
            PlayerInfoModel activePlayer = CreatePlayer("Player 1");  //usersname, shiplocations, shotgrid
            PlayerInfoModel opponent     = CreatePlayer("Player 2");

            PlayerInfoModel winner = null;

            do
            {
                //display grid from player 1 on where they fired.
                DisplayShotGrid(activePlayer);

                //ask activePlayer for a shot
                //determine if it is a valid shot
                //determine shot results
                RecordPlayerShot(activePlayer, opponent);

                //determine if game is over
                bool doesGameContinue = GameLogic.PlayerStillActive(opponent);

                //if over, set activePlayer as winner
                //else swap positions (activePlayer to opponent)
                if (doesGameContinue == true)
                {
                    //Use tuple to swap positions
                    (activePlayer, opponent) = (opponent, activePlayer);
                }
                else
                {
                }
            } while (winner == null);
            IdentifyWinner(winner);
            Console.ReadLine();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            WelcomeMessage();

            PlayerInfoModel activePlayer = CreatePlayer("Player 1");
            PlayerInfoModel opponent     = CreatePlayer("Player 2");
            PlayerInfoModel winner       = null;

            do
            {
                DisplayShotGrid(activePlayer);

                RecordPlayershot(activePlayer, opponent);

                bool doesGameContinue = GameLogic.PlayerStillActive(opponent);

                if (doesGameContinue == true)
                {
                    // Swap positions using tuple
                    (activePlayer, opponent) = (opponent, activePlayer);

                    // Swap positions using temp variable
                    //PlayerInfoModel tempHolder = opponent;
                    //opponent = activePlayer;
                    //activePlayer = tempHolder;
                }
                else
                {
                    winner = activePlayer;
                }
            } while (winner == null);

            IdentifyWinner(winner);

            Console.ReadLine();
        }