/******************************************************************************
Assignment2ATest						                                 Hal Stringer
COP 3330.0002 - Object Oriented Programming  			            1/28/05	
Spring 2005
  
This class contains code which will exercise/test each student's MyConsoleIO
program.  The code includes methods to test input of integers, doubles and 
strings as well as methods that test left, right and center justification of 
those same data types.  Each output test includes a version which will use
even-length, odd-length and over-length strings in even length fields, odd
length fields and feilds of size equal to the string.

******************************************************************************/

public class Assignment2ATest{

	public static void main(String[] args) throws java.io.IOException {

		int length=0;				// Hold length of field for each test
		int aInteger=0;		//	Holds test integer number
		double aDouble=0; 	//	Holds test double number
		String aString="";	//	Holds test character string

		//	TEST MyConsoleIO METHODS WHICH RETURN INPUT FROM CONSOLE

		//	Prompt user to enter an integer.  
		// Print integer as left, center and right justified on same line
		MyConsoleIO.leftPrint("Enter an integer number:", 30);
		aInteger = MyConsoleIO.getInteger();
		System.out.println();
		System.out.print("|");
		MyConsoleIO.leftPrint(aInteger, 10);
		System.out.print("|");
		MyConsoleIO.centerPrint(aInteger, 10);
		System.out.print("|");
		MyConsoleIO.rightPrint(aInteger, 10);
		System.out.print("|\n\n");

		//	Prompt user to enter an double number.  
		// Print double as left, center and right justified on same line
		MyConsoleIO.leftPrint("Enter a double number:", 30);
		aDouble = MyConsoleIO.getDouble();
		System.out.println();
		System.out.print("|");
		MyConsoleIO.leftPrint(aDouble, 10);
		System.out.print("|");
		MyConsoleIO.centerPrint(aDouble, 10);
		System.out.print("|");
		MyConsoleIO.rightPrint(aDouble, 10);
		System.out.print("|\n\n");

		//	Prompt user to enter a character string.  
		// Print string as left, center and right justified on different lines
	   MyConsoleIO.leftPrint("Enter a character string:", 30);
		aString = MyConsoleIO.getString();
		System.out.println();
		System.out.print("|");
		MyConsoleIO.leftPrint(aString, 40);
		System.out.print("|\n");

		System.out.print("|");
		MyConsoleIO.centerPrint(aString, 40);
		System.out.print("|\n");

		System.out.print("|");
		MyConsoleIO.rightPrint(aString, 40);
		System.out.print("|\n\n");

		//	TEST MyConsoleIO METHODS WHICH HANDLE OUTPUT TO THE CONSOLE
		// Each test is run eight times with a different size integer and field length

		System.out.println("Testing for Integer Output in 8/9-space field:\n");
		for (int i=1; i<=8; i++){

			if      (i==1){aInteger = 9999; length=4;}			// Even, Equal
			else if (i==2){aInteger = 99999; length=5;}		 	//	Odd, Equal
			else if (i==3){aInteger = 9999; length=8;}			// Even, Even
			else if (i==4){aInteger = 99999; length=8;}		 	//	Odd, Even
			else if (i==5){aInteger = 1234567899; length=8;} 	// Overflow, Even
			else if (i==6){aInteger = 9999; length=9;}			//	Odd, Odd
			else if (i==7){aInteger = 99999; length=9;}			//	Odd, Odd
			else if (i==8){aInteger = 1234567899; length=9;} 	// Overflow, Odd

			System.out.print("|");
			MyConsoleIO.leftPrint(aInteger, length);
			System.out.print("|");
			MyConsoleIO.centerPrint(aInteger, length);
			System.out.print("|");
			MyConsoleIO.rightPrint(aInteger, length);
			System.out.println("|");
		}

		System.out.println("\n\nTesting for Double Output in 10/11-space field:\n");
		for (int i=1; i<=8; i++){

			if      (i==1){aDouble = 12.3; length=4;}						// Even, Equal
			else if (i==2){aDouble = 1234.56; length=7;}				 	//	Odd, Equal
			else if (i==3){aDouble = 12.3; length=10;}					// Even, Even
			else if (i==4){aDouble = 1234.56; length=10;}				//	Odd, Even
			else if (i==5){aDouble = 1234567.7654321; length=10;} 	// Overflow, Even
			else if (i==6){aDouble = 12.3; length=11;}					//	Odd, Odd
			else if (i==7){aDouble = 1234.56; length=11;}				//	Odd, Odd
			else if (i==8){aDouble = 1234567.7654321; length=11;} 	// Overflow, Odd

			System.out.print("|");
			MyConsoleIO.leftPrint(aDouble, length);
			System.out.print("|");
			MyConsoleIO.centerPrint(aDouble, length);
			System.out.print("|");
			MyConsoleIO.rightPrint(aDouble, length);
			System.out.println("|");
		}

		System.out.println("\n\nTesting for String output in 20/21-space field:\n");
		for (int i=1; i<=8; i++){

			if      (i==1){aString = "AN EVEN STRING"; length=14;}	// Even, Equal
			else if (i==2){aString = "AN ODD STRING"; length=13;}		//	Odd, Equal
			else if (i==3){aString = "AN EVEN STRING"; length=20;}	// Even, Even
			else if (i==4){aString = "AN ODD STRING"; length=20;}		//	Odd, Even
			else if (i==5){aString = "A STRING THAT IS WAY TOO LONG TO FIT IN THE FIELD";
											  length=20;} 							// Overflow, Even
			else if (i==6){aString = "AN EVEN STRING"; length=21;}	//	Odd, Odd
			else if (i==7){aString = "AN ODD STRING"; length=21;}		//	Odd, Odd
			else if (i==8){aString = "A STRING THAT IS WAY TOO LONG TO FIT IN THE FIELD";
											 length=21;} 							// Overflow, Odd

			System.out.print("|");
			MyConsoleIO.leftPrint(aString, length);
			System.out.print("|");
			MyConsoleIO.centerPrint(aString, length);
			System.out.print("|");
			MyConsoleIO.rightPrint(aString, length);
			System.out.println("|");
		}

		//  All tests completed, end program
		System.out.println ("\n\nEnd of program. Goodbye.");
      
	}  // End of main() method

}  // End of Assignment2ATest.java


