Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace LegendaryFearming
  8. {
  9.  
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14.  
  15. var template = 0;
  16.  
  17.  
  18. var materialsCollection = new Dictionary<string, long>();
  19.  
  20. materialsCollection["shards"] = 0;
  21. materialsCollection["fragments"] = 0;
  22. materialsCollection["motes"] = 0;
  23. string legendaryItem = "";
  24. var input = String.Empty;
  25. bool breakPoint = true;
  26.  
  27. while (breakPoint)
  28. {
  29. input = Console.ReadLine();
  30. var items = input.ToLower().Split();
  31. long quantity = 0;
  32. string material = "";
  33. for (int index = 1; index <= items.Length; index += 2)
  34. {
  35. material = items[index];
  36. quantity = long.Parse(items[index - 1]);
  37.  
  38. if (!materialsCollection.ContainsKey(material))
  39. {
  40. materialsCollection[material] = 0;
  41. }
  42.  
  43. materialsCollection[material] += quantity;
  44.  
  45. if (materialsCollection[material] >= 250 && (material == "fragments" || material =="shards"
  46. || material == "motes"))
  47. {
  48. materialsCollection[material] -= 250;
  49. legendaryItem = material;
  50. breakPoint = false;
  51. break;
  52. }
  53. }
  54.  
  55.  
  56. }
  57.  
  58. if (legendaryItem == "shards")
  59. {
  60. Console.WriteLine("Shadowmourne obtained!");
  61. }
  62. else if (legendaryItem == "fragments")
  63. {
  64. Console.WriteLine("Valanyr obtained!");
  65. }
  66. else if (legendaryItem == "motes")
  67. {
  68. Console.WriteLine("Dragonwrath obtained!");
  69. }
  70.  
  71. var sortedKeyItems = materialsCollection.Take(3).OrderByDescending(x => x.Value).ThenBy(x => x.Key);
  72. var sortedJunksItems = materialsCollection.Skip(3).OrderBy(a => a.Key);
  73.  
  74. foreach (var sortedKeyMaterial in sortedKeyItems)
  75. {
  76. var item = sortedKeyMaterial.Key;
  77. var value = sortedKeyMaterial.Value;
  78. Console.WriteLine($"{item}: {value}");
  79. }
  80.  
  81. foreach (var sortedJunkMaterial in sortedJunksItems)
  82. {
  83. Console.WriteLine($"{sortedJunkMaterial.Key}: {sortedJunkMaterial.Value}");
  84. }
  85. }
  86.  
  87.  
  88.  
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement