import javabook.*;

/**
 * This class is the top-level controller object for managing
 * all other objects in the EggyPeggy program.
 *
 * @author Dr. Caffeine
 *
 */
class EggyPeggy                // Step2: Input and Output Routines
{

//--------------------------------
//    Data Members
//--------------------------------

    private MainWindow        mainWindow;
    private InputBox          inputBox;
    private OutputBox         outputBox; 
    private ResponseBox       responseBox;
    
    /**
     * Input string to convert
     */
    private String            inputString;
    
    /**
     * Converted Eggy-Peggy string
     */
    private String            eggyPeggyString;

//--------------------------------
//    Constructors
//--------------------------------

    /**
     * Default constructor. 
     * The default window title is "Let’s Play EggyPeggy".
     */
    public EggyPeggy( )
    {
        mainWindow     = new MainWindow  ("Let’s Play EggyPeggy");
        outputBox      = new OutputBox   ( mainWindow );
        responseBox    = new ResponseBox ( mainWindow );
        inputBox       = new InputBox    ( mainWindow );
    
        mainWindow.show();
        outputBox.show();
    }        


//-------------------------------------------------
//        Public Methods:
// 
//            void        start        (        )
//
//------------------------------------------------

    /**
     * Top-level method that calls other private methods
      * to play the Eggy-Peggy games.     
     */
    public void start ( )
    {
        int answer;
        
        describeGame();

        answer = responseBox.prompt("Do you want to play Eggy-Peggy?");

        while ( answer == ResponseBox.YES ) {

            getInput( );
            generateEggyPeggy( );                            
            displayResult( );                            

            answer 
            = responseBox.prompt("Do you want to play another Eggy-Peggy?");
        }
    }

//-------------------------------------------------
//        Private Methods:
// 
//        void     describeGame        (            )
//        void     displayResult       (            )
//        void     generateEggyPeggy   (            )
//        void     getInput            (            )
//
//------------------------------------------------
    
    /**
     * Provides a brief explanation of the program to the user.     
     *
     */    
    private void describeGame( )
    {
        outputBox.printLine("Inside describeGame");       //TEMP
    }


    /**
     * Show the input string and the eggy-peggy string generated
     * from the input string.
     *     
     */
    private void displayResult( )
    {
        outputBox.skipLine(3);                    
        outputBox.printLine("Input String:");
        outputBox.printLine("      " +     inputString);
        
        outputBox.skipLine(1);
        outputBox.printLine("Eggy Peggy:");
        outputBox.printLine("      " +     eggyPeggyString);   //TEMP
    }
    

    /**
     * Generate a new string from the input string by putting the 
     * word "egg" in front of all vowels in the input string. 
     *
     */    
    private void generateEggyPeggy( )
    {
        eggyPeggyString = "Dummy Eggy Peggy String";
        
        outputBox.printLine("Inside generateEggyPeggy");  //TEMP
    }


    /**
     * Read in the input string using InputBox.
     *
     */
    private void getInput( )
    {
        inputString = inputBox.getString("Enter the original sentence:");                                                            //TEMP
    }    

}