// Class to test the Maths1 class 
// Author Chris IOAKIM

import java.io.*;
import Maths1.*;
public class TestMaths1
{
	public static void main ( String args[]) throws IOException
	{
		int x, y, z; // sets up the integers
		String s;
		String answer; // for repetition loop 
		int choice; // for switch
		
		// set up the buffered reader 
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		do
		{ // start of the do while loop 
			
			System.out.flush();
		
			System.out.println("Menu for additions");
			System.out.println("Enter 1 for additions :");
			System.out.println("Enter 2 for divisions :");
			System.out.println("Enter 3 for Square    :");
		
			s=in.readLine();
			choice = Integer.parseInt(s);
			
			switch(choice)
			{
				case 1: // Additions class 
				System.out.println("You have selected the additions");
				System.out.flush();
				System.out.println("Please Enter the first number ");
				s=in.readLine();
				x=Integer.parseInt(s);
				System.out.println("Please enter the second number");
				System.out.flush();
				s=in.readLine();
				y=Integer.parseInt(s);
				System.out.flush();
				System.out.println("Please enter the third and final number");
				s=in.readLine();
				z=Integer.parseInt(s);
				
				Maths1 m1= new Maths1(x,y,z); // initialises and instantiaites a new Maths1 object
				System.out.println("The sum of the integers " + x + " " + y +" " + z +" is " + m1.getAddition());
				System.out.flush();
				
				break; // ends first switch
				
				case 2:
				System.out.println("You have selected the divitions ");
				System.out.flush();
				System.out.println("Please enter the first number ");
				s=in.readLine();
				x=Integer.parseInt(s);
				System.out.flush();
				System.out.println("Please enter the second number ");
				s=in.readLine();
				y=Integer.parseInt(s);
				System.out.flush();
				Maths1 m2 = new Maths1(x,y);
				System.out.println("The division of the numbers " + x + " " + y + " is " + m2.getDivision());
				System.out.flush();
				
				break; // ends division switch
				
				case 3:
				System.out.println("You have selected the square : ");
				System.out.flush();
				System.out.println("Please enter the number ");
				s=in.readLine();
				x=Integer.parseInt(s); 
				System.out.flush();
				Maths1 m3 = new Maths1(x);
				System.out.println("The square of the number " + x + " is " + m3.getSquare());
				
				break;
				
				default:
				System.out.println("Please choose a number between 1 - 3");
				break;
			}
			System.out.println("Do you want to continue. Enter Y to carry on or anything else to stop");
			answer=in.readLine();
			System.out.flush();
		}while(answer.equalsIgnoreCase("Y"));
		
	}			
}		
	