Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Loops
- {
- class Program
- {
- static void Main(string[] args)
- {
- string namePlayer1 = Console.ReadLine();
- string namePlayer2 = Console.ReadLine();
- string command = Console.ReadLine();
- int playerCard1 = 0;
- int playerCard2 = 0;
- int player1points = 0;
- int player2points = 0;
- while (command != "End of game")
- {
- playerCard1 = int.Parse(command);
- playerCard2 = int.Parse(Console.ReadLine());
- if (playerCard1 > playerCard2)
- {
- player1points += playerCard1 - playerCard2;
- }
- else if (playerCard2 > playerCard1)
- {
- player2points += playerCard2 - playerCard1;
- }
- else
- {
- Console.WriteLine("Number wars!");
- int newCard1 = int.Parse(Console.ReadLine());
- int newCard2 = int.Parse(Console.ReadLine());
- if (newCard1 > newCard2)
- {
- Console.WriteLine($"{namePlayer1} is winner with {player1points} points");
- }
- else
- {
- Console.WriteLine($"{namePlayer2} is winner with {player2points} points");
- }
- break;
- }
- command = Console.ReadLine();
- if (command == "End of game")
- {
- Console.WriteLine($"{namePlayer1} has {player1points} points");
- Console.WriteLine($"{namePlayer2} has {player2points} points");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement