// Test programme to test the area class
// author Chris Ioakim
// dated 27.10.01

import java.io.*;

public class TestArea
{
	public static void main (String args[])throws IOException
	{
		int choice;
		String answer; // for while loop
		String s;
		int x,y;
		double z;
	
		// set up the buffer reader and input stream
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		do
		{ // start of the do while loop
			System.out.flush();
		
			System.out.println("Menu :"); // Set up a quick menu for the user to choose the area
			System.out.println("Enter 1 for the area of a square ");
			System.out.println("Enter 2 for the area of a rectangle ");
			System.out.println("Enter 3 for the area of a circle ");
		
			s=in.readLine();// read in the users choice 
			choice = Integer.parseInt(s);// convert the string into the an integer
		
		
			switch(choice)
				{
					case 1://Square
					System.out.println("You have selected the area of a square ");
					System.out.println("Enter the side of the square ");
					System.out.flush(); // clears the data input stream
					s=in.readLine(); // read the size of the square in
					x=Integer.parseInt(s); // converts the string into an integer
					Area a1 = new Area(x); // initialises a new object of Area
					System.out.println("The area of a square with side = " + x + " has an area of " + a1.getAreaSquare());
				
					break;
				
					case 2: // Rectangle
					System.out.println("You have selected the area of a rectangle ");
					System.out.println("Enter the side of the rectangle ");
					System.out.flush();// Clears the input stream	
					s=in.readLine();// reads in the side of the rectangle
					x=Integer.parseInt(s);// converts the string into an integer
					System.out.flush();// clears the stream
					System.out.println("Enter the length of the rectangle ");
					s=in.readLine();// reads in the length of the rectangle 
					y=Integer.parseInt(s);//converts the string into an integer
					Area a2 = new Area(x,y);// calls and initialises a new instance of the area class
					System.out.println("The area of the rectangle with sides " + x + ", " + y + " is equals " + a2.getAreaRectangle());
				
					break;
				
				case 3: // circle
					System.out.println("You have selected the area of a cirlcle ");
					System.out.println("Enter the radius of the circle ");
					System.out.flush(); // clears the data input stream
					s=in.readLine();
					Double l=Double.valueOf(s); //converts the string into a double	
					z=l.doubleValue();
					Area a3= new Area(z); // initialises a new instance of the area class
					System.out.println("The area of a circle with radius " + z + " has area " + a3.getAreaCircle());
				
					break;
				
				default:
					System.out.println("Enter a number 1,2 or 3");
					System.out.flush();
					break;
				
				}
				
			System.out.println("Do you want to continue or stop. Type Y to continue or anything else to stop ");
			System.out.flush();
			answer=in.readLine();
				
		}while (answer.equalsIgnoreCase("Y"));
	}// ends the main
	
}// ends the class TestArea		