/*
****************************************************************************
*  Kelli Wiseth
*  kelli@alameda-tech-lab.com
*  CIS 255AX
*  Program name: ComplexTest.java
*  Program Description: The driver program for the Complex class. This class
*    instantiates four Complex objects and runs through using all the methods
*    of each object--the add(), subtract(), multiply(), divide() methods--and
*    displays the results. 
*
*  Assignment #3
*  10 March 2005
****************************************************************************
*/

import java.awt.*;        // Container, FlowLayout
import javax.swing.*;     // JApplet, JButton, JLabel, JTextField
import java.util.*;       // StringTokenizer, Pattern

public class ComplexTest extends JFrame {

   JButton exitButton;
   JTextArea outputArea;
   String output;
 
   // calling the superclass' constructor to setup and instantiate GUI

   public ComplexTest()
   {
    // call JFrame constructor to set title bar string
    super( "Kelli Wiseth ComplexTest Program" );
  
    // obtain content pane and set layout to FlowLayout
    Container container = getContentPane();
    container.setLayout( new FlowLayout() );
    outputArea = new JTextArea( 10, 33 );   //rows x columns
    outputArea.setEditable( false );

    /**********************************************************
     * The next four calls create four instances of the Complex class object.
     * (We don't use the default constructor in this version of the
     * ComplexTest class, but the default constructor has been tested.)
     **********************************************************
     */
    Complex complexNumOne   = new Complex(9.5, 7.7);
    Complex complexNumTwo   = new Complex(1.2, 3.1);
    Complex complexNumThree = new Complex(4.0, 3.0);
    Complex complexNumFour  = new Complex(2.0, 1.5);
    
    /**********************************************************
     * The next several lines layout the output so that the four 
     * Complex numbers [test data] display within the top of a table; the 
     * names of the operations display on the left-hand side; and 
     * the results form two columns under the test data.  
     *************************************************************
    */
    output =  "\t\tTest numbers";
    output += "\n\t1) " + complexNumOne.toString() + "\t\t3) " + complexNumThree.toString();
    output += "\n\t2) " + complexNumTwo.toString() + "\t\t4) " + complexNumFour.toString();
    output += "\n-------------------------------------------------------------------------------------";
    output += "\nOperation\t\tResults";
    output += "\n---------------\t---------------------------------------------------------------";
    output += "\nAdd\t";
    output += complexNumOne.add(complexNumTwo).toString() + "\t\t" +
              complexNumThree.add(complexNumFour).toString();
  
    output += "\nSubtract\t";
    output += complexNumOne.subtract(complexNumTwo).toString() + "\t\t" +
              complexNumThree.subtract(complexNumFour).toString();
  
    output += "\nMultiply\t";
    output += complexNumOne.multiply(complexNumTwo).toString() + "\t\t" +
              complexNumThree.multiply(complexNumFour).toString();
  
    output += "\nDivide\t";
    output += complexNumOne.divide(complexNumTwo).toString() + "\t\t" +
              complexNumThree.divide(complexNumFour).toString();
  
    outputArea.append(output);
    container.add(new JScrollPane(outputArea));
    setSize( 410, 225 );  // set the window size in pixels (width x height)
    setVisible( true );   // show the window
  
   }// end constructor ComplexTest

   public static void main(String args[]) 
     {
 	 ComplexTest application = new ComplexTest();
	 application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
  	 } // main method closing brace
  	 
} // ComplexTest class definition closing brace
