Advertisement
Guest User

Untitled

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