//***********************************************************************//
//* 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 <string.h>            // for terminal input/output
#include "Game.h"              // include the header file

void main()
{
	 char name[len];
	 football game(name);
	 baseball baseballgame(name);
	 


	 char choice = '1';                // user's choice


	 while(choice != '3')  // 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

			

				 // prompt user enter the name of the team

				 cout << "\n\tPlease enter the name of the team: ";

				 cin.getline(name, len);
				 cin.getline(name, len);

				
				 // declare a variable of type football

				 game.SetName(name);
				

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

				 
				 game.display();

				 while(choice1 != '4')  // 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.show_stats();
						 game.display();
						 break;

					 case '2':

								  // call the function stats()

						 game.show_stats();
						 game.display();
						 break;

					 case '3':

								  // call the function play a game

						 game.play_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";
					 choice = '3';
					 break;
					 


					 default:

				     // if choice is invalid display error message

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

					}   
				 }// End switch statement
				 break;

		  case '2':



			 // prompt user enter the name of the team

			 cout << "\n\tPlease enter the name of the team: ";

			 cin.getline(name, len, '\n');
			 cin.getline(name, len, '\n');

 			 baseballgame.SetName(name);
		


			 // open display, set the data members to some initial values
			 
			 baseballgame.display();

			 while(choice1 != '4')  // 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()

						baseballgame.display();
						break;

				 case '2':

						// call the function stats()

			  			 baseballgame.show_stats();
						 baseballgame.display();
						 break;

				 case '3':

						// call the function play a game

						 baseballgame.play_game();
						 baseballgame.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";
					  choice = '3';
					  break;
					  //exit(0);

				  default:

						 // if choice is invalid display error message

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

				  }             // End switch statement
			 }
			 break;

		 // 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";
			 break;

			 default:

			// if choice is invalid display error message

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

		 }

	}                          // End of while(1)

}                                // End main()

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