Difference between revisions of "DisplayWinner"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
The display winner shows the winner between any amount of players.   
 
The display winner shows the winner between any amount of players.   
  
 +
'''Winner Winner Chicken Dinner!'''
 
<syntaxhighlight lang="csharp">
 
<syntaxhighlight lang="csharp">
private static void DisplayWinner(int PlayerOneScore, int PlayerTwoScore)
+
private static void DisplayWinner(int PlayerOneScore, int PlayerTwoScore) // declares PlayerOneScore and PlayerTwoScore as a number
 
         {
 
         {
 
             Console.WriteLine();
 
             Console.WriteLine();
             Console.WriteLine("**** GAME OVER! ****");
+
             Console.WriteLine("**** GAME OVER! ****"); // displays the game as being finished
 
             Console.WriteLine();
 
             Console.WriteLine();
             Console.WriteLine("Player One your score is " + PlayerOneScore);
+
             Console.WriteLine("Player One your score is " + PlayerOneScore); // Displays Player ones score.
             Console.WriteLine("Player Two your score is " + PlayerTwoScore);
+
             Console.WriteLine("Player Two your score is " + PlayerTwoScore); // Displays player twos score.
             if (PlayerOneScore > PlayerTwoScore)
+
             if (PlayerOneScore > PlayerTwoScore)   // if player one has a higher score than player 2 then player one wins.
 
             {
 
             {
                 Console.WriteLine("Player One wins!");
+
                 Console.WriteLine("Player One wins!"); // displays player one has won.
 
             }
 
             }
             else if (PlayerTwoScore > PlayerOneScore)
+
             else if (PlayerTwoScore > PlayerOneScore) // if player two has a higher score than player one then player two wins.
 
             {
 
             {
                 Console.WriteLine("Player Two wins!");
+
                 Console.WriteLine("Player Two wins!"); //displays player 2 has won.
 
             }
 
             }
 
             else
 
             else
 
             {
 
             {
                 Console.WriteLine("It is a draw!");
+
                 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();
 
             Console.WriteLine();
 
         }
 
         }
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 09:06, 16 November 2017

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();
        }