Class PokemonFactory
java.lang.Object
Pokemon.PokemonFactory
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionpokemonFactory(String pokemonToBeCreated) Creates a newPokemoninstance based on the provided Pokémon name.
-
Constructor Details
-
PokemonFactory
public PokemonFactory()
-
-
Method Details
-
pokemonFactory
Creates a newPokemoninstance based on the provided Pokémon name.The method is case-insensitive. If the name does not match any known Pokémon, an
IllegalArgumentExceptionis 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
-