Class PokemonFactory

java.lang.Object
Pokemon.PokemonFactory

public class PokemonFactory extends Object
Factory class for creating Pokemon instances.

This class implements the Factory design pattern, centralizing the creation of Pokémon objects based on their names. Pokémon names are treated case-insensitively. Adding new Pokémon requires updating this factory.

  • Constructor Details

    • PokemonFactory

      public PokemonFactory()
  • Method Details

    • pokemonFactory

      public Pokemon pokemonFactory(String pokemonToBeCreated)
      Creates a new Pokemon instance based on the provided Pokémon name.

      The method is case-insensitive. If the name does not match any known Pokémon, an IllegalArgumentException is thrown.

      Parameters:
      pokemonToBeCreated - the name of the Pokémon to create
      Returns:
      a new instance of the specified Pokemon
      Throws:
      IllegalArgumentException - if the Pokémon name is not recognized