import javabook.*;

/*
 * Introduction to OOP with Java 2nd Edition, McGraw-Hill
 *	
 *  A sample program to test the selection sort defined
 *  in the SortingRoutines class.
 *  
 * @author Dr. Caffeine
 *
 */
class TestSelectionSort
{
    
    
    public static void main (String[] args)
    {
        MainWindow  mainWindow;
        OutputBox 	outputBox;
        
        mainWindow = new MainWindow("Test Selection Sort");
        outputBox  = new OutputBox( mainWindow );
                
        mainWindow.setVisible( true );
        outputBox.setVisible( true );
        
        int[ ] number = new int[50];
        
        SortingRoutines sorter = new SortingRoutines( );    
        
        //Store random numbers between 0 and 9999
        //into an array of int.
        //Duplicate values in the array are okay
        
                for (int i = 0; i < number.length; i++ ) {
            
            number[ i ]   = (int) Math.floor( Math.random() * 10000 );
            
            outputBox.printLine( number[ i ] );
        }
        
        //Display the array elments before sorting
        outputBox.printLine( " Unsorted List " );
        outputBox.skipLine( 1 );
        
        for (int i = 0; i < number.length; i++ ) {
            
            outputBox.printLine( number[ i ] );
        }   
        
        //Sort
        sorter.selectionSort( number );
        
        
        //Display the array elments after sorting
        outputBox.printLine( " Unsorted List " );
        outputBox.skipLine( 1 );
        
        for (int i = 0; i < number.length; i++ ) {
            
            outputBox.printLine( number[ i ] );
        }
        
 
    }
    
}