Advertisement
aggressiveviking

Untitled

Feb 14th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P04_EasterEggsBattle
  4. {
  5.     class P04_EasterEggsBattle
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int countEggs1 = int.Parse(Console.ReadLine());
  10.             int countEggs2 = int.Parse(Console.ReadLine());
  11.  
  12.             //докато: End или яйцата на някого свършат
  13.  
  14.             int points1 = 0;
  15.             int points2 = 0;
  16.             String winner = Console.ReadLine();
  17.  
  18.             while (winner != "End of battle")
  19.             {
  20.                 if (winner == "one")
  21.                 {
  22.                     countEggs2--;
  23.                 }
  24.                 else if (winner == "two")
  25.                 {
  26.                     countEggs1--;
  27.                 }
  28.  
  29.                 if (countEggs1 == 0)
  30.                 {
  31.                     Console.WriteLine($"Player one is out of eggs. Player two has {countEggs2} eggs left.");
  32.                     break;
  33.                 }
  34.                 else if (countEggs2 == 0)
  35.                 {
  36.                     Console.WriteLine($"Player two is out of eggs. Player one has {countEggs1} eggs left.");
  37.                     break;
  38.                 }
  39.  
  40.                 winner = Console.ReadLine();
  41.             }
  42.  
  43.             if (winner == "End of battle")
  44.             {
  45.                 Console.WriteLine($"Player one has {countEggs1} eggs left.");
  46.                 Console.WriteLine($"Player two has {countEggs2} eggs left.");
  47.             }
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement