import javabook.*;

/*
 * Introduction to OOP with Java 2nd Edition, McGraw-Hill
 *	
 *   A sample program that illustrates the basic use of the 
 *   Format class from Section 7.7.
 *   
 *  
 * @author Dr. Caffeine
 *
 */
class TestFormat
{
    
    public static void main (String[] args)
    {
        
        MainWindow   mainWindow        = new MainWindow();
        OutputBox    outputBox         = new OutputBox(mainWindow);
        
        mainWindow.setVisible( true );
        outputBox.setVisible( true );
       
        //declare all variables first
        int i, j, k, l;
        
        double x, y, z, w;
        
        //Figure 7.12
        outputBox.printLine("Figure 7.12 Outputs");
        outputBox.skipLine( 1 );
        
        i = 12; j = 6789; k = 908766;
        x = 123.4; y = 2.90899; z = 900.0;
        
        outputBox.printLine("i " + i);
        outputBox.printLine("j " + j);
        outputBox.printLine("k " + k);
        
        outputBox.printLine("x " + x);
        outputBox.printLine("y " + y);
        outputBox.printLine("z " + z);
        
        outputBox.skipLine( 2 );
        
        //Figure 7.13
        outputBox.printLine("Figure 7.13 Outputs");
        outputBox.skipLine( 1 );
        
        outputBox.printLine( "i " + Format.rightAlign(10, i) );
        outputBox.printLine( "j " + Format.rightAlign(10, j) );
        outputBox.printLine( "k " + Format.rightAlign(10, k) );
        
        outputBox.printLine( "x " + Format.rightAlign(10, 3, x) );
        outputBox.printLine( "y " + Format.rightAlign(10, 3, y) );
        outputBox.printLine( "z " + Format.rightAlign(10, 3, z) );
        
        outputBox.skipLine( 2 );
        

        //Figure 7.14
        outputBox.printLine("Figure 7.14 Outputs");
        outputBox.skipLine( 1 );
        
        i = 1234; j = 567; k = 89; l = 123456789;

        outputBox.printLine( Format.leftAlign(6,i) + "I" );
        outputBox.printLine( Format.leftAlign(6,j) + "Love" );
        outputBox.printLine( Format.leftAlign(6,k) + "Java" );
        outputBox.printLine( Format.leftAlign(6,l) + "Programming");
        outputBox.skipLine(1);
        
        outputBox.printLine( Format.rightAlign(6,i) );
        outputBox.printLine( Format.rightAlign(6,j) );
        outputBox.printLine( Format.rightAlign(6,k) );
        outputBox.printLine( Format.rightAlign(6,l) );
        outputBox.skipLine(1);
        
        outputBox.printLine( Format.centerAlign(6,i) + "Yes" );
        outputBox.printLine( Format.centerAlign(6,j) + "Java" );
        outputBox.printLine( Format.centerAlign(6,k) + "Is" );
        outputBox.printLine( Format.centerAlign(6,l) + "Hot" );

        outputBox.skipLine( 2 );
        
        //Figure 7.15
        outputBox.printLine("Figure 7.15 Outputs");
        outputBox.skipLine( 1 );
        
        for (int width = 10; width > 5; width-- )
            outputBox.printLine( Format.rightAlign(width, "Jakarta") );
  
        outputBox.skipLine( 2 );
        
        //Figure 7.16
        outputBox.printLine("Figure 7.16 Outputs");
        outputBox.skipLine( 1 );
        
        x = -123.4; y = 5.67; z = 8.911; w = 12345.6789;

        outputBox.printLine( Format.leftAlign(6,2,x) + "I" );
        outputBox.printLine( Format.leftAlign(6,2,y) + "Love" );
        outputBox.printLine( Format.leftAlign(6,2,z) + "Java" );
        outputBox.printLine( Format.leftAlign(6,2,w) 
                                + "Programming");
        outputBox.skipLine(1);
        
        outputBox.printLine( Format.rightAlign(6,3,x) );
        outputBox.printLine( Format.rightAlign(6,3,y) );
        outputBox.printLine( Format.rightAlign(6,3,z) );
        outputBox.printLine( Format.rightAlign(6,3,w) );
        outputBox.skipLine(1);
        
        outputBox.printLine(Format.centerAlign(6,1,x) + "Yes");
        outputBox.printLine(Format.centerAlign(6,1,y) + "Java");
        outputBox.printLine(Format.centerAlign(6,1,z) + "Is");
        outputBox.printLine(Format.centerAlign(6,1,w) + "Hot");

        outputBox.skipLine( 2 );
        
    }
    
}