You are on page 1of 4

Villanueva, Strawmile A

2 – CS3

Midterms Act 1

Codiva Link: https://www.codiva.io/p/936649dc-e32a-4e02-9aeb-da8a372a4d07

Code:

import java.util.ArrayList;

import java.util.Scanner;
class Pokemon {

private String name;

private String type;

private String ability;

public Pokemon(String name, String type, String ability) {

this.name = name;

this.type = type;

this.ability = ability;

public String getName() {

return name;

public String getType() {

return type;

public String getAbility() {

return ability;

@Override

public String toString() {

return "Pokemon{" + "name='" + name + '\'' + ", type='" + type + '\'' + ", ability='" + ability + '\''+'}';

}
public class pokeDex{

private static ArrayList<Pokemon> pokemonList = new ArrayList<>();

static {

pokemonList.add(new Pokemon("Bulbasaur", "Grass/Poison","Chloropyl"));

pokemonList.add(new Pokemon("Ivysaur", "Grass/Poison","Chloropyl"));

pokemonList.add(new Pokemon("Vensaur", "Grass/Poison","Chloropyl"));

pokemonList.add(new Pokemon("Charmander", "Fire","Blaze"));

pokemonList.add(new Pokemon("Charmeleon", "Fire","Blaze"));

pokemonList.add(new Pokemon("Charizard", "Fire/Flying","Blaze"));

pokemonList.add(new Pokemon("Squirtle", "Water","Torrent"));

pokemonList.add(new Pokemon("Wartortle", "Water","Torrent"));

pokemonList.add(new Pokemon("Blastoise", "Water","Torrent"));

public static Pokemon getPokemonByName(String name) {

for (Pokemon pokemon : pokemonList) {

if (pokemon.getName().equalsIgnoreCase(name)) {

return pokemon;

return null;

public static void printPokedex() {

System.out.println("Starter Pokemons:");

for (Pokemon pokemon : pokemonList) {

System.out.println(pokemon);
}

public static void main(String[] args) {

printPokedex();

Scanner scanner = new Scanner(System.in);

System.out.print("Enter the name of the Pokemon to search: ");

String pokemonNameToSearch = scanner.nextLine();

Pokemon foundPokemon = getPokemonByName(pokemonNameToSearch);

if (foundPokemon != null) {

System.out.println("Found Pokemon: " + foundPokemon);

} else {

System.out.println("Not a Starter Pokemon!: " + pokemonNameToSearch);

scanner.close();

You might also like