Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _04.Pokemon_Evolution
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = "";
- List<PokemonEvolution> listOfPokemons = new List<PokemonEvolution>();
- while ((input = Console.ReadLine()) != "wubbalubbadubdub")
- {
- if (listOfPokemons.Select(x => x.Name).Contains(input))
- {
- printPokemon(input, listOfPokemons);
- continue;
- }
- string[] slitedInput = input.Split(new string[] { " ", "-", ">" }, StringSplitOptions.RemoveEmptyEntries);
- if (slitedInput.Length != 3)
- {
- continue;
- }
- PokemonEvolution pokemons = new PokemonEvolution();
- pokemons.Name = slitedInput[0];
- if (!listOfPokemons.Select(x => x.Name).Contains(slitedInput[0]))
- {
- pokemons.Name = slitedInput[0];
- pokemons.Evolution = new List<string>();
- pokemons.Index = new List<int>();
- pokemons.Evolution.Add(slitedInput[1]);
- pokemons.Index.Add(int.Parse(slitedInput[2]));
- listOfPokemons.Add(pokemons);
- }
- else
- {
- for (int i = 0; i < listOfPokemons.Count; i++)
- {
- if (listOfPokemons[i].Name == slitedInput[0])
- {
- listOfPokemons[i].Evolution.Add(slitedInput[1]);
- listOfPokemons[i].Index.Add(int.Parse(slitedInput[2]));
- }
- }
- }
- }
- foreach (var item in listOfPokemons)
- {
- Console.WriteLine($"# {item.Name}");
- //item.Evolution = item.Evolution.OrderBy(x => item.Index.IndexOf(y)).ToList();
- item.Index = item.Index.OrderByDescending(x => x).ToList();
- for (int i = 0; i < item.Index.Count; i++)
- {
- Console.WriteLine("{0} <-> {1}", item.Evolution[i], item.Index[i]);
- }
- }
- }
- private static void printPokemon(string input, List<PokemonEvolution> listOfPokemons)
- {
- foreach (var item in listOfPokemons.Where(x => x.Name == input))
- {
- Console.WriteLine(item.Name);
- for (int i = 0; i < item.Index.Count; i++)
- {
- Console.WriteLine("{0} <-> {1}", item.Evolution[i], item.Index[i]);
- }
- }
- }
- }
- class PokemonEvolution
- {
- public string Name { get; set; }
- public List<string> Evolution { get; set; }
- public List<int> Index { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment