Class Raichu

java.lang.Object
Pokemon.Pokemon
Pokemon.Electricity.Raichu

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

Raichu has two available attacks:

  • Agility: Deals base damage plus any elemental bonus. Performs a coin flip; if heads, Raichu becomes invincible for the opponent's next turn.
  • Thunder: Deals base damage plus any elemental bonus. Performs a coin flip; if tails, Raichu damages itself for 30 HP.
This class defines Raichu'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 Raichu.
  • Constructor Details

    • Raichu

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

    • getAttackResult1

      public int getAttackResult1(ElementType elementTypeOfOpponentPokemon)
      Executes Raichu's Agility attack.

      Deals damage equal to the attack's base damage plus any elemental bonus against the opponent's type. A coin flip determines whether Raichu becomes invincible for the opponent's next turn.

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

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

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

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

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

      Executes Agility if attack equals 1; otherwise, executes Thunder and may damage Raichu 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 Agility, others for Thunder)