Class Trainer

java.lang.Object
Trainer.Trainer

public class Trainer extends Object
Represents a Pokémon trainer who can own and manage Pokémon in battles.

Each trainer has a name, a current Pokémon, a faint counter, and a life status. The faint counter decreases when the trainer's Pokémon faints, and the alive status indicates whether the trainer can continue participating in battles.

  • Field Details

    • trainerName

      private final String trainerName
      The name of the trainer.
    • currentPokemon

      private Pokemon currentPokemon
      The Pokémon the trainer is currently using in battle.
    • faintCounter

      private int faintCounter
      Counts how many times the trainer's Pokémon have fainted.
    • ifTrainerIsAlive

      private boolean ifTrainerIsAlive
      Indicates whether the trainer is still considered alive in the battle.
  • Constructor Details

    • Trainer

      public Trainer(String trainerName)
      Constructs a new Trainer with the specified name.
      Parameters:
      trainerName - the name of the trainer
  • Method Details

    • getName

      public String getName()
      Returns the name of the trainer.
      Returns:
      the trainer's name
    • getFaintCounter

      public int getFaintCounter()
      Returns the number of remaining faints before the trainer is considered defeated.
      Returns:
      the faint counter
    • getIfTrainerIsAlive

      public boolean getIfTrainerIsAlive()
      Checks if the trainer is still alive and able to battle.
      Returns:
      true if the trainer is alive; false otherwise
    • setIfTrainerIsAlive

      public void setIfTrainerIsAlive(boolean isAlive)
      Sets the trainer's alive status.
      Parameters:
      isAlive - true if the trainer is alive; false if defeated
    • decreaseFaintCounter

      public void decreaseFaintCounter()
      Decreases the faint counter by one.

      This method is typically called when the trainer's current Pokémon faints.

    • getCurrentPokemon

      public Pokemon getCurrentPokemon()
      Returns the Pokémon the trainer is currently using in battle.
      Returns:
      the current Pokemon instance
    • setCurrentPokemon

      public void setCurrentPokemon(Pokemon newPokemon)
      Sets the trainer's current Pokémon.
      Parameters:
      newPokemon - the Pokemon to assign as the current Pokémon