Advertisement
Valantina

GameNumberWars/EX

Jun 13th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 KB | None | 0 0
  1. using System;
  2.  
  3. namespace GameNumberWars
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string playerOneName = Console.ReadLine();
  10.             string playerTwoName = Console.ReadLine();
  11.  
  12.             int playerOnePoints = 0;
  13.             int playerTwoPoints = 0;
  14.  
  15.             while (true)
  16.             {
  17.                 string commands = Console.ReadLine();
  18.  
  19.                 if (commands.Equals("End of game"))
  20.                 {
  21.                     Console.WriteLine($"{playerOneName} has {playerOnePoints} points");
  22.                     Console.WriteLine($"{playerTwoName} has {playerTwoPoints} points");
  23.                     break;
  24.                 }
  25.  
  26.                 int cardPlayerOne = int.Parse(commands);
  27.                 int cardPlayerTwo = int.Parse(Console.ReadLine());
  28.  
  29.                 if (cardPlayerOne.Equals(cardPlayerTwo))
  30.                 {
  31.  
  32.                     Console.WriteLine("Number wars!");
  33.                     int numberWarsCardOne = int.Parse(Console.ReadLine());
  34.                     int numbersWarsCardTwo = int.Parse(Console.ReadLine());
  35.  
  36.                     if (numbersWarsCardTwo > numberWarsCardOne)
  37.                     {
  38.                         Console.WriteLine($"{playerTwoName} is winner with {playerTwoPoints} points");
  39.                     }
  40.                     else
  41.                     {
  42.                         Console.WriteLine($"{playerOneName} is winner with {playerOnePoints} points");
  43.                     }
  44.                     break;
  45.                 }
  46.                 else if (cardPlayerOne > cardPlayerTwo)
  47.                 {
  48.                     playerOnePoints += cardPlayerOne - cardPlayerTwo;
  49.                 }
  50.                 else
  51.                 {
  52.                     playerTwoPoints += cardPlayerTwo - cardPlayerOne;
  53.                 }
  54.             }
  55.         }
  56.     }
  57.    
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement