Class Pikachu

java.lang.Object
Pokemon.Pokemon
Pokemon.Electricity.Pikachu

public class Pikachu extends Pokemon
Represents the Pokémon Pikachu, an Electric-type Pokémon.

Pikachu has two available attacks:

  • Gnaw: Deals base damage plus any elemental bonus against the opponent.
  • Thunder Jolt: Deals base damage plus any elemental bonus. Performs a coin flip; if tails, Pikachu takes 10 damage itself.
This class defines Pikachu's specific attack logic and overrides the abstract Pokemon.hitOpponent(Pokemon, int) method.
  • Field Details

    • attackInfo

      private final AttackInfo[] attackInfo
      Array of attacks available to Pikachu.
  • Constructor Details

    • Pikachu

      public Pikachu()
      Constructs a new Pikachu Pokémon with default health, element type, ASCII art, and its two attacks.
  • Method Details

    • getAttackResult1

      public int getAttackResult1(ElementType elementTypeOfOpponentPokemon)
      Executes Pikachu's Gnaw attack.

      Deals damage equal to the attack's base damage plus any elemental bonus against the opponent's type.

      Parameters:
      elementTypeOfOpponentPokemon - the element type of the opponent Pokémon
      Returns:
      the total damage dealt by Gnaw
    • getAttackResult2

      public int getAttackResult2(ElementType elementTypeOfOpponentPokemon)
      Executes Pikachu's Thunder Jolt attack.

      Deals damage equal to the attack's base damage plus any elemental bonus against the opponent's type. A coin flip determines whether Pikachu damages itself for 10 HP.

      Parameters:
      elementTypeOfOpponentPokemon - the element type of the opponent Pokémon
      Returns:
      the total damage dealt by Thunder Jolt
    • hitOpponent

      public void hitOpponent(Pokemon OpponentPokemon, int attack)
      Performs an attack on an opponent Pokémon.

      Executes Gnaw if attack equals 1; otherwise, executes Thunder Jolt and may damage Pikachu itself based on a coin flip.

      Specified by:
      hitOpponent in class Pokemon
      Parameters:
      OpponentPokemon - the Pokémon being attacked
      attack - the index of the attack to use (1 for Gnaw, others for Thunder Jolt)