//Program to calculate the GCD of 2 numbers
//By Neil Broadbent

import java.io.*;
import java.util.StringTokenizer;
import GCDClass.*;

public class GCD
{
    public static void main(String[] pArgs) throws IOException
        {

	/** @param N1 & N2 the values for working out the GCD
	 *  precondition tK & tN >= 1
	 *  @return GCD so that GCD<=0 */

            boolean debugging = true;

            final BufferedReader tKeyboard = new BufferedReader(new InputStreamReader(System.in));

            System.out.print("Type in the first  numbers in the form 4,5 ");
            final String tInput = tKeyboard.readLine();
            StringTokenizer tTokensOnLine = new StringTokenizer(tInput, ",");

            String tThisToken = tTokensOnLine.nextToken();
            int N1 = new Integer(tThisToken).intValue();

            tThisToken = tTokensOnLine.nextToken();
            int N2 = new Integer(tThisToken).intValue();	

		/* check pre-condition */
		if (debugging && ((N1<=0) || (N2<=0))){
			System.out.println("Pre-condition violoated");
		}

                final GCDInterface tGCD = new GCDClass(N1,N2);
                System.out.println("The GCD is " + tGCD.getGCD());	

		/* check post-condition */
                int Posttest=tGCD.getGCD();
                if (debugging && (Posttest<=0)){
                    System.out.println("Post-condition violoated");
                }	
        }
}
