//**********************************************************************
// Name: Huy Nguyen
// Date:  6/5/1999
// Project: Classes
// File name : main.cpp
// Description: This is the main funtion for the program, that will 
//              display the menu of the options, and will call the 
//              appropriate function upon the user's choices.
//
//**********************************************************************

#include "game.h"              // include the header file

void main()
{  
    char choice;                // user's choice
    

    while(1)  // Display Menu until the user choose to quit
    {
        // Display menu of choices

        cout << endl;
        cout << "\t********************************************\n";
        cout << "\t*                                          *\n";
        cout << "\t*  1- Play football                        *\n";
        cout << "\t*  2- Play baseball                        *\n";
        cout << "\t*  3- Quit                                 *\n";
        cout << "\t*                                          *\n";
        cout << "\t********************************************\n";

        cout << "\n\tChoice:  "; // prompt users for choice
        cin >> choice;
        cout << endl;

        // Execute user's choice

        switch (choice)
        {
        case '1':
			

            char choice1;         // user's choice

            char name1[len];      // name of the team

		 // prompt user enter the name of the team

		 cout << "\n\tPlease enter the name of the team: ";
			
		 cin.getline(name1, len, '\n');

		 // declare a variable of type football

		 football game(name1);

		 // open display, set the data members to some initial values

		 game.display();

		 while(1)  // Display Menu until the user choose to quit

		 // Display menu of choices

		 cout << endl;
		 cout << "\t***************************************\n";
		 cout << "\t*                                     *\n";
		 cout << "\t*  1- Display                         *\n";
		 cout << "\t*  2- Show Stats                      *\n";
		 cout << "\t*  3- Play game                       *\n";
		 cout << "\t*  4- Quit                            *\n";
		 cout << "\t*                                     *\n";
		 cout << "\t***************************************\n";

                 cout << "\n\tChoice: ";     // prompt users for choice
		 cin >> choice1;
		 cout << endl;

		 switch (choice1)
		 {
		 case '1':

                 // call the function display()

		    game.display();
		    break;

		 case '2'

                 // call the function stats()     
				  
		    game.show_stats(double per, double per1);
		    game.display();
		    break;

		 case '3'

                 // call the function play a game

		    game.play_a_game();
		    game.display();
		    break;

                 // if the person want to quit the program
		 // and if they chooce invalid code

                 case '4':
		
                 // quit the program

                 cout << "\n\n\tBye! and have a nice day :-)\n\n";
                 exit(0);

                 default:

                 // if choice is invalid display error message

                 cerr << "\n\t\tINVALID CHOICE!!! :-(\n\n";
                 break;

            	 }             // End switch statement
 
        case '2':

	    char choice3;         // user's choice

            char name3[len];      // name of the team

	    // prompt user enter the name of the team

	    cout << "\n\tPlease enter the name of the team: ";
			
	    cin.getline(name3, len, '\n');

	    // declare a variable of type football

	    baseball game(name3);

	    // open display, set the data members to some initial values

	    game.display1();

	    while(1)  // Display Menu until the user choose to quit

	    // Display menu of choices

	    cout << endl;
	    cout << "\t***************************************\n";
	    cout << "\t*                                     *\n";
	    cout << "\t*  1- Display                         *\n";
	    cout << "\t*  2- Show Stats                      *\n";
	    cout << "\t*  3- Play game                       *\n";
	    cout << "\t*  4- Quit                            *\n";
	    cout << "\t*                                     *\n";
	    cout << "\t***************************************\n";

            cout << "\n\tChoice: ";     // prompt users for choice
	    cin >> choice1;
	    cout << endl;

	    switch (choice1)
	    {
	    case '1':

            // call the function display()

	         game.display1();
	         break;

	    case '2'

            // call the function stats()      
				  
	         game.show_stats1(double error);
		 game.display1();
		 break;

	    case '3'

            // call the function play a game

	         game.play_a_game1();
		 game.display1();
		 break;

            // if the person want to quit the program
	    // and if they chooce invalid code

            case '4':
		
                 // quit the program

                 cout << "\n\n\tBye! and have a nice day :-)\n\n";
                 exit(0);

                 default:

                      // if choice is invalid display error message

                      cerr << "\n\t\tINVALID CHOICE!!! :-(\n\n";
                      break;

              	  }             // End switch statement
 
            // if the person want to quit the program
	    // and if they chooce invalid code
		
	    case '3':

	    // quit the program

	    cout << "\n\tBye! and have a nice day: )\n";
	    exit(0);

	    default:

		// if choice is invalid display error message

	        cerr << "\n\tInvalid Choice!!!:-(\n\n";

	    }

      }                          // End of while(1)

}                                // End main()

//-------------------------------------------------------------------------
