public bool LoadJSON(string path) { Clear(); bool success = false; try { using (StreamReader reader = new StreamReader(path)) { string jsonData = reader.ReadToEnd(); PokeDex temp = JsonConvert.DeserializeObject <PokeDex>(jsonData); if (temp != null) { this.Clear(); this.AddRange(temp); } success = true; } } catch (Exception) { Console.WriteLine("An exception occurred attempting to access {0}", path.ToString()); } return(success); }
public List <Pokemon> GetAllPokemonOfType(Pokemon.PokemonType type) { // create list to save pokemon of same type PokeDex pokemons = new PokeDex(); // check each pokemon for the matching type foreach (Pokemon pokemon in this) { if (pokemon.Type1 == type || pokemon.Type2 == type) { pokemons.Add(pokemon); } } // return a PokeDex containing only pokemon of matching type return(pokemons); }
public void SetUp() { inputPath = CombineToAppPath(INPUT_FILE); outputPath = CombineToAppPath(OUTPUT_FILE); pokedex = new PokeDex(); }