Advertisement
Stan0033

Untitled

Jul 21st, 2021
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5.  
  6. namespace apps
  7. {
  8. class Program
  9. {
  10.  
  11. static string Get() { return Console.ReadLine(); }
  12.  
  13. static void Main()
  14. {
  15. SortedDictionary<string, int> collection = new SortedDictionary<string, int>();
  16. bool FoundLegendary = false;
  17. while (FoundLegendary == false)
  18. {
  19. string input = Get();
  20. string[] parts = input.Split(' ').ToArray();
  21.  
  22. for (int i = 1; i < 6; i += 2)
  23. {
  24. string resource = parts[i].ToLower();
  25. int value = int.Parse(parts[i - 1]);
  26. if (collection.ContainsKey(resource)) { collection[resource] += value; }
  27. else { collection.Add(resource, value); }
  28.  
  29. }
  30.  
  31. if (collection.ContainsKey("shards"))
  32. {
  33. if (collection["shards"] >= 250)
  34. {
  35. collection["shards"] -= 250;
  36. Console.WriteLine("Shadowmourne obtained!");
  37. FoundLegendary = true;
  38. }
  39.  
  40. }
  41. if (collection.ContainsKey("fragments"))
  42. {
  43. if (collection["fragments"] >= 250)
  44. {
  45. collection["fragments"] -= 250;
  46. Console.WriteLine("Valanyr obtained!");
  47. FoundLegendary = true;
  48. }
  49. }
  50.  
  51. if (collection.ContainsKey("motes"))
  52. {
  53. if (collection["motes"] >= 250)
  54. {
  55. collection["motes"] -= 250;
  56. Console.WriteLine("Dragonwrath obtained!");
  57. FoundLegendary = true;
  58. }
  59. }
  60.  
  61.  
  62.  
  63. }
  64. collection.OrderByDescending(i => i.Value);
  65. collection.OrderBy(i => i.Key);
  66. foreach (var v in collection)
  67. {
  68.  
  69.  
  70. Console.WriteLine($"{v.Key}: {v.Value}");
  71. }
  72. }// END MAIN
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement