ralichka

Exam.20-21.April.2019-04.Easter.Eggs.Battle

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