CSE-8B / PA8 / starter / MinLevelException.java
MinLevelException.java
Raw
//File: MinLevelException.java
//Name: Trai Pham
//Date: 03/02/2020
//Course: CSE 8B
/**
The lowest level that a pokemon can have is lvl 1, it cannot be any level lower
than that
**/
public class MinLevelException extends Exception{
  private static final String EXCEPT_MSG = "%s can't be less than level 1!\n";
  private String pokemonName;

/**
@param String of the pokemon's Name
@return nothing
Constructor
**/
  public MinLevelException(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);
  }
}