CSE-8B / PA8 / starter / OutOfBoundsException.java
OutOfBoundsException.java
Raw
//File: OutOfBoundsException.java
//Name: Trai Pham
//Date: 03/02/2020
//Course: CSE 8B
/**
An exception used when the user attempts to access an invalid location in
our Pokemon storage system
**/
public class OutOfBoundsException extends Exception{
  private static final String EXCEPT_MSG = "Out of bounds: %s\n";
  private String errorLocation;

/**
@param String of the location that is out of bounds
@return nothing
Constructor
**/
  public OutOfBoundsException(String loc){
//formatting of Exception
    super(String.format(EXCEPT_MSG, loc));
    this.errorLocation = loc;
  }

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