CSE-8B / PA8 / starter / Squirtle.java
Squirtle.java
Raw
//File: Squirtle.java
//Name: Trai Pham
//Date: 03/02/2020
//Course: CSE 8B
/**
One of the starter pokemon, which is a water type pokemon
**/
import java.util.Random;

public class Squirtle extends Pokemon{
  private static final String NAME       = "Squirtle";
  private static final String DEX_NUMBER = "007";
  private static final int INITIAL_LEVEL = 5;
//constants variable so I don't use magic numbers
  public int damage3 = 3;
  public int damage8 = 8;

/**
@param nothing
@return nothing
Constructor
**/
  public Squirtle() throws MinLevelException, MaxLevelException{
    super(DEX_NUMBER, NAME, INITIAL_LEVEL);
  }

/**
@param nothing
@return int value
attack method that randomizes the damage of Squirtle. The damage has equal
chances to be 3 or 8
**/
  @Override
  public int attack(){
    Random randomSquirtleAtk = getRandom();
    int newAtk = randomSquirtleAtk.nextInt(1);
//Different damages that Squirtle can do 
    int squirtleDamage = 0;
    if(newAtk == 1){
      squirtleDamage = damage3;
    }
    else{
      squirtleDamage = damage8;
    }
    return squirtleDamage;
  }
}