Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.IO;
  5.  
  6. namespace ZaliczenieP7
  7. {
  8. class Program
  9. {
  10. public class Player
  11. {
  12. public string Nick { get; set; }
  13. public List<decimal?> Times { get; set; }
  14. public List<bool> Passed { get; set; }
  15. }
  16.  
  17.  
  18.  
  19. static void Main(string[] args)
  20. {
  21.  
  22. Console.WriteLine("Podaj liczbę etapów: ");
  23. int RoundCount = int.Parse(Console.ReadLine());
  24. Console.Clear();
  25.  
  26. Console.WriteLine("Zawodnik 1: ");
  27. string name1 = Console.ReadLine();
  28. Player player1 = new Player() { Nick = name1 };
  29. Console.WriteLine("Zawodnik 2: ");
  30. string name2 = Console.ReadLine();
  31. Player player2 = new Player() { Nick = name2 };
  32. Console.WriteLine("Zawodnik 3: ");
  33. string name3 = Console.ReadLine();
  34. Player player3 = new Player() { Nick = name3 };
  35.  
  36. void Start()
  37. {
  38. List<Player> Round = new List<Player>();
  39.  
  40. Console.WriteLine($"Czas zawodnika {player1.Nick}:");
  41. int time1 = int.Parse(Console.ReadLine());
  42. player1.Times.Add(time1);
  43. Console.WriteLine($"Czas zawodnika {player2.Nick}:");
  44. int time2 = int.Parse(Console.ReadLine());
  45. player2.Times.Add(time2);
  46. Console.WriteLine($"Czas zawodnika {player3.Nick}:");
  47. int time3 = int.Parse(Console.ReadLine());
  48. player3.Times.Add(time3);
  49. Round.Add(player1);
  50. Round.Add(player2);
  51. Round.Add(player3);
  52.  
  53. foreach (Player player in Round.OrderBy(x => x.Times[RoundCount - 1]))
  54. {
  55.  
  56.  
  57. if (player.Times[RoundCount] != 0)
  58. {
  59. Console.WriteLine($"Zawodnik: {player.Nick} Czas: {player.Times[RoundCount - 1]}");
  60. player.Passed.Add(true);
  61. }
  62.  
  63. else
  64. {
  65. Console.WriteLine($"Zawodnik: {player.Nick} nie ukończył etapu");
  66. player.Passed.Add(false);
  67. }
  68.  
  69.  
  70. }
  71.  
  72.  
  73. Console.ReadKey();
  74.  
  75. }
  76.  
  77. for (int i = 1; i < RoundCount + 1; i++)
  78. {
  79. Console.WriteLine($"Runda {i}");
  80. Start();
  81.  
  82. }
  83.  
  84. bool player1Pass = true;
  85. foreach (bool pass in player1.Passed)
  86. {
  87. if (pass == false)
  88. {
  89. player1Pass = false;
  90. break;
  91. }
  92. }
  93.  
  94. if (player1Pass != false)
  95. {
  96. Console.WriteLine(player1.Nick + " to straszny zjeb");
  97. }
  98. else
  99. {
  100. decimal result = 0;
  101. foreach (decimal time in player1.Times)
  102. {
  103. result += time;
  104. }
  105. Console.WriteLine(player1.Nick + " osiągnął końcowy wynik: " + result);
  106. }
  107.  
  108. }
  109. }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement