/*********************************************************************
* CS 239 - Advanced Programming; Lab 10-03
*
* @author - Michael H. Oliver
* @version - V1 1/17/2007
*********************************************************************/
//References and Acknowledgements: I received no outside help with
//this programming assignment.
//
//********************************************************************
import java.io.*;
public class Exceptions_Lab_olivermh_Exception
{
	/************************************************************
	*Contains methods designed to throw and catch the exceptions:
	*	ArrayIndexOutOfBounds
	*	Arithmetic (division by zero)
	*	NegativeArraySize
	*	IllegalArgument
	*	FileNotFound
	************************************************************/
	public static void main(String [] args)
	{
		try
		{
			int[] array;
			array = new int[1];
			array[1] = 1;
		}
		catch (ArrayIndexOutOfBoundsException aioobe)
		{
			System.out.print("Array index not valid.\n");
		}
		
		try
		{
			int digit = 2 / 0;
		}
		catch (ArithmeticException ae)
		{
			System.out.print("Cannot divide by zero.\n");
		}
		
		try
		{
			int[] array;
			array = new int[-1];
		}
		catch (NegativeArraySizeException nase)
		{
			System.out.print("Array size must be positive.\n");
		}
		
		try
		{
			int value;
			value = Integer.parseInt("string");
		}
		catch (IllegalArgumentException iae)
		{
			System.out.print("Illegal argument.\n");
		}
		
		try
		{
			FileReader reader = new FileReader("fakefile.txt");
		}
		catch (FileNotFoundException fnfe)
		{
			System.out.print("File does not exist.\n");
		}
		
		System.out.print("\nSuccess - all exceptions thrown.");
	}
}