/**
 * Example of a customized Exception class "NegativeException"
 * 
 * This exception stores the denominator that caused the problem
 * The toString() method then print a message and the offending denominator. 
 *
 * An Exception subclass must have at least 2 constructors, 
 * an empty (default) constructor, and a constructor that takes a string message
 * Any other constructors are your choice
 */

class NegativeException extends Exception
{
    private int denominator;                        //private field

    public NegativeException( ) {                   //default empty constructor
//      super()                                     //no need, automatically done by the JVM               
    }
    public NegativeException(String s) {            //constructor that takes a string message
        super(s);                                   //call the super constructor
    }
    public NegativeException(int n) {               //constructor that takes a number
//      super()                                     //no need, automatically done by the JVM               
        denominator = n;                    
    }
    public NegativeException(String s, int n) {     //constructor that takes a string and a number
        super(s);                                   //call the super constructor
        denominator = n;                    
    }

    public String toString( ) {
        return(super.toString( ) + " - Denominator cannot be negative. It is: " + denominator);
    }
}