Advertisement
Spocoman

Easter Eggs Battle

Nov 27th, 2021 (edited)
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2.  
  3. namespace EasterEggBattle
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int firstPlayer = int.Parse(Console.ReadLine());
  10.             int secondPlayer = int.Parse(Console.ReadLine());
  11.             string command = Console.ReadLine();
  12.  
  13.             while (command != "End")
  14.             {
  15.                 if (command == "one")
  16.                 {
  17.                     secondPlayer--;
  18.                     if (secondPlayer == 0)
  19.                     {
  20.                         Console.WriteLine($"Player two is out of eggs. Player one has { firstPlayer} eggs left.");
  21.                         break;
  22.                     }
  23.                 }
  24.                 else if (command == "two")
  25.                 {
  26.                     firstPlayer--;
  27.                     if (firstPlayer == 0)
  28.                     {
  29.                         Console.WriteLine($"Player one is out of eggs. Player two has { secondPlayer} eggs left.");
  30.                         break;
  31.                     }
  32.                 }
  33.                 command = Console.ReadLine();
  34.             }
  35.  
  36.             if (command == "End")
  37.             {
  38.                 Console.WriteLine($"Player one has { firstPlayer} eggs left.");
  39.                 Console.WriteLine($"Player two has { secondPlayer} eggs left.");
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement