public void Play()
{
io.WriteLine("Welcome to the Number Guessing Game!");
io.WriteLine("=====================================\n");
bool playOn = true;
while (playOn)
{
HandleUserInput();
io.WriteLine("Enter your username:\n");
string name = io.ReadLine();
IGoalGenerator goalGenerator = goalGeneratorFactory.CreateGoalGenerator();
IGuessChecker guessChecker = guessCheckerFactory.CreateGuessChecker();
string goal = goalGenerator.Generate();
io.WriteLine("New game:\n");
// Comment out or remove the next line to play real games!
io.WriteLine("For practice, the number is: " + goal + "\n");
string guess = io.ReadLine();
int nGuess = 1;
string bbcc = guessChecker.Check(goal, guess);
io.WriteLine(bbcc + "\n");
while (bbcc != "BBBB,")
{
nGuess++;
guess = io.ReadLine();
io.WriteLine(guess + "\n");
bbcc = guessChecker.Check(goal, guess);
io.WriteLine(bbcc + "\n");
}
playerDataStorage.Write(name, nGuess);
playerDataStorage.ShowTopList();
io.WriteLine("Correct, it took " + nGuess + " guesses.\nContinue?\n \"n\" for no or just press any key to continue");
string answer = io.ReadLine();
if (answer != null && answer != "" && answer.Substring(0, 1) == "n")
{
playOn = false;
}
}
}