DisplayWinner

From TRCCompSci - AQA Computer Science
Jump to: navigation, search

The display winner shows the winner between any amount of players.

Winner Winner Chicken Dinner!

private static void DisplayWinner(int PlayerOneScore, int PlayerTwoScore) // declares PlayerOneScore and PlayerTwoScore as a number 
        {
            Console.WriteLine();
            Console.WriteLine("**** GAME OVER! ****"); // displays the game as being finished
            Console.WriteLine();
            Console.WriteLine("Player One your score is " + PlayerOneScore);  // Displays Player ones score.
            Console.WriteLine("Player Two your score is " + PlayerTwoScore);  // Displays player twos score.
            if (PlayerOneScore > PlayerTwoScore)   // if player one has a higher score than player 2 then player one wins.
            {
                Console.WriteLine("Player One wins!"); // displays player one has won.
            }
            else if (PlayerTwoScore > PlayerOneScore) // if player two has a higher score than player one then player two wins.
            {
                Console.WriteLine("Player Two wins!"); //displays player 2 has won.
            }
            else
            {
                Console.WriteLine("It is a draw!");  // if neither player one or player two has a higher score(so they have the same score it is a draw.
            }
            Console.WriteLine();
        }