public static void main(String[] args) throws IOException
	{
		showInstructionMessage();
		
		//make sure the input is in correct format
		boolean successfulStart = false;
		
		MasterMind MMGame;
		int mode = 0;
		
		//a loop generates multiple games as long as the play would like to continue
		do
		{
			successfulStart = false;
			
			//a minimal initialized game enables the keyboard input
			MMGame = new MasterMind();
			
			//ask user to play or quit the game
			successfulStart = MMGame.startNewGame();
			
			//check the answer from the user and starts the game
			if (successfulStart)
			{
				//ask the user for the difficulty level of the game, 2 modes
				MMGame.setMode();
				
				//generate a new game with the user-defined mode setting
				mode = MMGame.getMode();
				MMGame = new MasterMind(mode);
			
				//generate answer based on the user-defined mode
				MMGame.answerGenerator = new MMAnswer(mode);
				MMGame.answer = MMGame.answerGenerator.getAnswer();
				
				//a loop asks the user to input all the guesses, each loop generates one guess
				//displays the key pegs, scores and total number of guesses at the end of each guess
				do
				{
					//ask the user to input one guess contains desired number of holes, 4 or 5, based on the user-defined mode
					//store each guess into the two-dimensional array
					MMGame.guess[MMGame.totalGuesses] = MMGame.getGuess();
					//compares the guess to the answer
					MMGame.guessEvaluator = new MMGuess(MMGame.guess[MMGame.totalGuesses], MMGame.answer);
					//check whether the user wins the game
					MMGame.winner = MMGame.guessEvaluator.evaluateGuess();
					//store each key into the two-dimensional arry for each guess
					MMGame.key[MMGame.totalGuesses] = MMGame.guessEvaluator.getKey();
					MMGame.guessEvaluator.getSingleHits();
					// Compute the total number of guesses
					MMGame.guessCount++;

					//display the key pegs for each guess
					System.out.print("\n                                                                         Your hits: ");
					for(int i = 0; i <= MMGame.key[MMGame.totalGuesses].length - 1; i++)
						System.out.print(MMGame.key[MMGame.totalGuesses][i] + " ");
					System.out.println();
					MMGame.totalGuesses ++;
					/*System.out.println("\nX = right color and right position, 2 points\n" +
						               "x = right color but wrong position, 1 point\n" + 
							           "0, color not exist");
					System.out.println("--------------------------------------------------------------------");
                                         
					//display the total points from scores of individual guesses
					System.out.print("Total points earned: " + MMGame.totalHits + "  ");
					
					System.out.println("Total number of guesses: " + MMGame.totalGuesses);
					System.out.println("********************************************************************");*/	
				}
				//check whether the user wins the game
				//if not, ask the user whether continue the game or start over or need a hint before next guess
				while (!MMGame.winner && MMGame.continueCurrentGame());
				
				//the current game ends if the user wins the game
				if (MMGame.winner)
				{
					// Show Contratulations and single game stats					
					System.out.println("Congratulations! You win!");
					System.out.println("********************************************************************");
					System.out.println("It took you " + MMGame.guessCount + " guesses.");
					System.out.println("********************************************************************");
					System.out.println("");
					
					// Save the game data
					// class object MMStatistics generates the Statistics Controller for each game
					MMStatistics statsController = new MMStatistics();
					statsController.saveStats(MMGame.guessCount, mode);
					
				}				
			}
			//game over if the user is not ready for the game
			else
			{
				break;
			}
		}
		//a new game will start if the user is ready for a new game
		while (successfulStart);
	}//main