Advertisement
radidim

P03. Legendary Farming (C# Shell App Paste)

Jul 25th, 2020
1,495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.11 KB | None | 0 0
  1. //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
  2. using System;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Collections.Generic;
  6.  
  7. namespace CSharp_Shell
  8. {
  9.  
  10.     public static class Program
  11.     {
  12.         public static void Main()
  13.         {
  14.             var dict = new Dictionary<string, int>();
  15.             dict["shards"] = 0;
  16.             dict["fragments"] = 0;
  17.             dict["motes"] = 0;
  18.             var trasch= new Dictionary<string, int>();
  19.             var isTrue = false;
  20.             while(true)
  21.             {
  22.      
  23.                 var input = Console.ReadLine().Split();
  24.                
  25.                 for(int i=0;i<input.Length;i+=2)
  26.                 {
  27.                     var material = input[i+1].ToLower();
  28.                     var quantity = int.Parse(input[i]);
  29.                        
  30.                     if(material == "shards" || material == "fragments" ||material=="motes")
  31.                     {
  32.                         dict[material] += quantity;
  33.                         if(dict[material] >= 250)
  34.                         {
  35.                             dict[material] -= 250;
  36.                             if(material == "shards")
  37.                             {
  38.                             Console.WriteLine("Shadowmourne obtained!");
  39.                             }
  40.                        
  41.                        
  42.                             else if(material == "fragments")
  43.                             {
  44.                                 Console.WriteLine("Valanyr obtained!");
  45.                            
  46.                             }
  47.                             else
  48.                             {
  49.                             Console.WriteLine("Dragonwrath obtained!");
  50.                             }
  51.                            
  52.                             isTrue=true;
  53.                             break;
  54.                         }
  55.                     }
  56.                     else
  57.                     {
  58.                         if(!trasch.ContainsKey(material))
  59.                         {
  60.                             trasch[material] = new int();
  61.                         }
  62.                         trasch[material] += quantity;
  63.                     }
  64.                
  65.                 }
  66.            
  67.            
  68.             if(isTrue)
  69.             {
  70.                 break;
  71.             }
  72.             }
  73.            
  74.             foreach(var kvp in dict.OrderByDescending(x=>x.Value).ThenBy(x=>x.Key))
  75.             {
  76.                 Console.WriteLine($"{kvp.Key}: {kvp.Value}");
  77.             }
  78.            
  79.            
  80.             foreach(var kvp in trasch.OrderBy(x=>x.Key))
  81.             {
  82.                 Console.WriteLine($"{kvp.Key}: {kvp.Value}");
  83.             }
  84.         }
  85.     }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement