Advertisement
petarkobakov

Game Number Wars

Mar 4th, 2020
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Game_Number_Wars
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string nameA = Console.ReadLine();
  10. string nameB = Console.ReadLine();
  11. string command = Console.ReadLine();
  12. int totalPointsA = 0;
  13. int totalPointsB = 0;
  14. int totalPoints1 = 0;
  15. int totalPoints2 = 0;
  16.  
  17.  
  18. while (command != "End of game")
  19. {
  20. string command2 = Console.ReadLine();
  21.  
  22. int cardA = int.Parse(command);
  23. int cardB = int.Parse(command2);
  24.  
  25. if (cardA > cardB)
  26. {
  27. int pointsA = cardA - cardB;
  28. totalPointsA += pointsA;
  29. }
  30. else if (cardB > cardA)
  31. {
  32. int pointsB = cardB - cardA;
  33. totalPointsB += pointsB;
  34. }
  35. else if (cardA == cardB)
  36. {
  37.  
  38. command = Console.ReadLine();
  39. command2 = Console.ReadLine();
  40. int card1 = int.Parse(command);
  41. int card2 = int.Parse(command2);
  42.  
  43. if (card1 > card2)
  44. {
  45. int points1 = card1 - card2;
  46. totalPoints1 += points1;
  47. Console.WriteLine($"Number wars!");
  48. Console.WriteLine($"{nameA} is winner with { totalPointsA} points");
  49. return;
  50. }
  51. else if (card2 > card1)
  52. {
  53. int points2 = card2 - card1;
  54. totalPoints2 += points2;
  55. Console.WriteLine($"Number wars!");
  56. Console.WriteLine($"{nameB} is winner with {totalPointsB} points");
  57. return;
  58.  
  59. }
  60.  
  61. }
  62. command = Console.ReadLine();
  63. }
  64.  
  65. Console.WriteLine($"{nameA} has {totalPointsA} points");
  66. Console.WriteLine($"{nameB} has {totalPointsB} points");
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement