Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _04.GameNumberWars
- {
- class GameNumberWars
- {
- static void Main(string[] args)
- {
- string playerOne = Console.ReadLine();
- string playerTwo = Console.ReadLine();
- string cardFirstPlayer = Console.ReadLine();
- string cardSecondPlayer = "";
- int pointsOne = 0;
- int pointsTwo = 0;
- int result = 0;
- string warCard1 = "";
- string warCard2 = "";
- while (cardFirstPlayer != "End of game")
- {
- cardSecondPlayer = Console.ReadLine();
- int one = Convert.ToInt32(cardFirstPlayer);
- int two = Convert.ToInt32(cardSecondPlayer);
- if (one > two)
- {
- result = one - two;
- pointsOne += result;
- }
- else if (one < two)
- {
- result = two - one;
- pointsTwo += result;
- }
- else if (one == two)
- {
- Console.WriteLine("Number wars!");
- warCard1 = Console.ReadLine();
- warCard2 = Console.ReadLine();
- int war1 = Convert.ToInt32(warCard1);
- int war2 = Convert.ToInt32(warCard2);
- if (war1 > war2)
- {
- Console.WriteLine($"{playerOne} is winner with {pointsOne} points");
- break;
- }
- else
- {
- Console.WriteLine($"{playerTwo} is winner with {pointsTwo} points");
- break;
- }
- }
- cardFirstPlayer = Console.ReadLine();
- }
- if (cardFirstPlayer == "End of game")
- {
- Console.WriteLine($"{playerOne} has {pointsOne} points");
- Console.WriteLine($"{playerTwo} has {pointsTwo} points");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment