/* 
   Name: Instructor
   Course: CSCI 201
   Purpose: generate and catch an exception
*/

import cs1.Keyboard; 

public class Exceptional
{
    public static void main (String[] args)
    {
	int age;
	for(int i=0; i<4; i++)
	{
	    System.out.println("Please enter your age as an integer number");
	    age=Keyboard.readInt();
	    try {
		exceptionGenerator(age);
	    }
	    catch(GettingUpThereException tom) {
		System.out.println("An exception has occurred: " + tom.getMessage());
	    }
	}
    }


    public static void exceptionGenerator (int num) throws GettingUpThereException 
    {
	GettingUpThereException jerry = 
	    new GettingUpThereException("Young at heart is a wonderful thing");
	if (num>=80)
	    throw jerry;
	else
	    System.out.println("You're pretty young"); 
    }
}


class GettingUpThereException extends Exception 
{
    GettingUpThereException (String message) 
    {
	super (message); 
    }
} 


 
