Advertisement
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.PokemonEvolutionWithClass
- {
- public class PokemonEvolutionWithClass
- {
- public static void Main()
- {
- var input = Console.ReadLine();
- var pokemons = new List<Pokemon>();
- while (input != "wubbalubbadubdub")
- {
- var inputArgs = input.Split(new[] {" -> "}, StringSplitOptions.RemoveEmptyEntries);
- if (inputArgs.Length == 1)
- {
- var currentName = inputArgs[0];
- var currentPokemon = pokemons.Where(x => x.Name == currentName).FirstOrDefault();
- if (currentPokemon != null)
- {
- Console.WriteLine($"# {currentName}");
- foreach (var pokemon in pokemons.Where(x => x.Name == currentName))
- {
- Console.WriteLine($"{pokemon.EnvironmentType} <-> {pokemon.Id}");
- }
- }
- }
- else
- {
- var name = inputArgs[0];
- var environmentType = inputArgs[1];
- var id = long.Parse(inputArgs[2]);
- var currentPokemon = new Pokemon(name, environmentType, id);
- pokemons.Add(currentPokemon);
- }
- input = Console.ReadLine();
- }
- foreach (var pokemonName in pokemons.Select(x => x.Name).Distinct())
- {
- Console.WriteLine($"# {pokemonName}");
- foreach (var pokemon in pokemons.Where(x => x.Name == pokemonName).OrderByDescending(x => x.Id))
- {
- Console.WriteLine($"{pokemon.EnvironmentType} <-> {pokemon.Id}");
- }
- }
- }
- }
- public class Pokemon
- {
- public string Name { get; set; }
- public string EnvironmentType { get; set; }
- public long Id { get; set; }
- public Pokemon(string name, string environmentType, long id)
- {
- this.Name = name;
- this.EnvironmentType = environmentType;
- this.Id = id;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement