MeGaDeTH_91

04. Pokemon Evolution

Jul 9th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 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 _04.Pokemon_Evolution
  8. {
  9. class Pokemon
  10. {
  11. public string Evo { get; set; }
  12. public int Index { get; set; }
  13. }
  14. class Program
  15. {
  16. static void Main(string[] args)
  17. {
  18. string input = Console.ReadLine();
  19. Dictionary<string, List<Pokemon>> pokemonReg = new Dictionary<string, List<Pokemon>>();
  20. while (input != "wubbalubbadubdub")
  21. {
  22. string[] splitedInput = input
  23. .Split(new char[] { ' ', '-', '>' }, StringSplitOptions.RemoveEmptyEntries)
  24. .ToArray();
  25. if (splitedInput.Length == 1)
  26. {
  27. string pokemName = splitedInput[0];
  28. if (pokemonReg.ContainsKey(pokemName))
  29. {
  30. foreach (var currPoke in pokemonReg)
  31. {
  32. if (currPoke.Key == pokemName)
  33. {
  34. Console.WriteLine($"# {currPoke.Key}");
  35. foreach (var it in currPoke.Value)
  36. {
  37. Console.WriteLine($"{it.Evo} <-> {it.Index}");
  38. }
  39.  
  40.  
  41. }
  42.  
  43. }
  44. }
  45. }
  46. else
  47. {
  48. string currPokem = splitedInput[0];
  49. string currEvo = splitedInput[1];
  50. int currIndex = int.Parse(splitedInput[2]);
  51.  
  52.  
  53.  
  54.  
  55. if (!pokemonReg.ContainsKey(currPokem))
  56. {
  57. List<Pokemon> currList = new List<Pokemon>();
  58. currList.Add(new Pokemon());
  59. currList[0].Evo = currEvo;
  60. currList[0].Index = currIndex;
  61. pokemonReg[currPokem] = new List<Pokemon>(currList);
  62.  
  63. //pokemonReg[currPokem][0][currEvo] = currIndex;
  64. }
  65. else
  66. {
  67. List<Pokemon> currPokemon = new List<Pokemon>();
  68. currPokemon.Add(new Pokemon());
  69. currPokemon[0].Evo = currEvo;
  70. currPokemon[0].Index = currIndex;
  71. pokemonReg[currPokem].Add(currPokemon[0]);
  72. }
  73. }
  74.  
  75. input = Console.ReadLine();
  76. }
  77. foreach (var pok in pokemonReg)
  78. {
  79. Console.WriteLine($"# {pok.Key}");
  80. foreach (var i in pok.Value.OrderByDescending(x => x.Index))
  81. {
  82. Console.WriteLine($"{i.Evo} <-> {i.Index}");
  83. }
  84. }
  85. }
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment