Advertisement
viraco4a

03.ArenaTournament

Mar 12th, 2018
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace ArenaTournament
  5. {
  6.  
  7. class Arena
  8. {
  9. public double Discount { get; set; }
  10. public string Name { get; set; }
  11. public List<string> dayOfWeek { get; set; }
  12. }
  13.  
  14. class Program
  15. {
  16. static void Main()
  17. {
  18. int numberOfPoints = int.Parse(Console.ReadLine());
  19. string arenaName = Console.ReadLine();
  20. string dayOfWeek = Console.ReadLine();
  21. string itemType = Console.ReadLine();
  22. var allArenas = new List<Arena>(3);
  23. GenerateArenaList(allArenas);
  24. var types = new Dictionary<string, int>()
  25. {
  26. { "Poor", 7000 }, { "Normal", 14000 }, { "Legendary", 21000 }
  27. };
  28. double TotalPrice = types[itemType];
  29. foreach (var arena in allArenas)
  30. {
  31. if (arena.Name == arenaName && arena.dayOfWeek.Contains(dayOfWeek))
  32. {
  33. TotalPrice *= (1 - arena.Discount);
  34. }
  35. }
  36. double itemPrice = TotalPrice / 5.0;
  37. if (TotalPrice > numberOfPoints)
  38. {
  39. double items = Math.Floor(numberOfPoints / itemPrice);
  40. double pointsLeft = numberOfPoints - items * itemPrice;
  41. Console.WriteLine($"Items bought: {items}");
  42. Console.WriteLine($"Arena points left: {pointsLeft}");
  43. Console.WriteLine("Failure!");
  44. }
  45. else
  46. {
  47. int items = 5;
  48. double pointsLeft = numberOfPoints - items * itemPrice;
  49. Console.WriteLine($"Items bought: {items}");
  50. Console.WriteLine($"Arena points left: {pointsLeft}");
  51. Console.WriteLine("Success!");
  52. }
  53. }
  54.  
  55. private static void GenerateArenaList(List<Arena> allArenas)
  56. {
  57. var firstArena = new Arena
  58. {
  59. Name = "Nagrand",
  60. dayOfWeek = new List<string> { "Monday", "Wednesday" },
  61. Discount = 0.05
  62. };
  63. var secondArena = new Arena
  64. {
  65. Name = "Gurubashi",
  66. dayOfWeek = new List<string> { "Tuesday", "Thursday" },
  67. Discount = 0.1
  68. };
  69. var thirdArena = new Arena
  70. {
  71. Name = "Dire Maul",
  72. dayOfWeek = new List<string> { "Friday", "Saturday" },
  73. Discount = 0.07
  74. };
  75. allArenas.Add(firstArena);
  76. allArenas.Add(secondArena);
  77. allArenas.Add(thirdArena);
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement