CSE-8B / PA8 / starter / MaxLevelException.java
MaxLevelException.java
Raw
//File: MaxLevelException.java
//Name: Trai Pham
//Date: 03/02/2020
//Course: CSE 8B
/**
Whenever a pokemon Exceeds lvl 100(max lvl) and cannot level up anymore
**/
//Java implicilty imports the exception in the package of java.lang
public class MaxLevelException extends Exception{
  private static final String EXCEPT_MSG =
    "%s can't be greater than level 100!\n";
  private String pokemonName;

/**
@param String of the pokemon's Name
@return nothing
Constructor
**/
  public MaxLevelException(String name){
//formatting of Exception
    super(String.format(EXCEPT_MSG, name));
    this.pokemonName = name;
  }

/**
@param nothing
@return Strings
prints the message
**/
  @Override
  public String toString(){
    return String.format(EXCEPT_MSG, this.pokemonName);
  }
}