Difference between revisions of "DisplayWinner"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
Line 2: Line 2:
  
 
<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>

Revision as of 14:32, 14 November 2017

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

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