package exercise5;
/**
* Author: W. M. Farmer
* Revised: March 19, 2007
*
* Description: Exception that results when an index is out of range.
*
* @author W. M. Farmer
*/
public class BadIndexException extends Exception {
private Element element_;
private int index_;
/**
* Constructs the BadIndexException.
*
* @param e the Element that raised the exception
* @param i the index that raised the exception
*/
public BadIndexException(Element e, int i) {
element_ = e;
index_ = i;
}
/**
* Creates a String description of the exception.
*
* @return a String
*/
public String toString() {
return "exercise5.BadIndexException: The Element " +
element_.toString() +
" does not have an entry at index" +
String.valueOf(index_) +
".";
}
}