Open mayisa87 opened 11 months ago
Methods are actually not yet part of the exercises, as told before. You will learn about them, and how to use them right, later on in later modules. I see that you want to make your loop better readable, by calling the method inside. That's nice in general. But, if you use a method, never do methods in a method.
So your Main(string[] args) is a method, and your RunHangmanGame() is a method, that is declared inside the scope of your Main method. This is not nice.
So if you want to stick to the method here, better move the whole method outside of your Main and do it like:
public static RunHangmanGame()
{
....
}
Why, you will learn later on ;) Or... just move all the code you do in the RunHangmanGame in the loop, and don't use a method at all for now ;)
And second thing, if you ask the user to enter something, stick to the choices you give the user. I know, using console means that choices are limited and not that nice as in an grapical user interface, but, you could output "Do you want to try again? Enter y to continue or n to stop): " and then use Console.ReadKey().KeyChar to ask for the exact char the user pressed.
I'm not a fan of letting the user enter whole strings like "yes" as it is always a prone to errors
Something you will need a lot, also in next exercises, is to ask user if he wants to play again.
So after the user guessed the word, or reached max tries, you could ask, if he/she wants to play again and start over again.