Console.WriteLine("ALL WORDS YOU TYPE MUST BE LOWERCASE UNLESS STATED OTHERWISE, DO
YOU UNDERSTAND? \n \n YES | NO \n");
string answer = "undefined";
userInput();
answer = Console.ReadLine();
userInputDone();
if (answer == "yes")
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("\nGreat :)\n");
Console.ForegroundColor = ConsoleColor.Gray;
}
else if (answer == "no")
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\nTOO BAD\n");
Console.ForegroundColor = ConsoleColor.Gray;
}
Console.WriteLine("What would you lke to do? \n \n PLAY | INSTRUCTIONS");
I'm working on a text-based game to get used to C#, how would i go about looping the if statement so that if the user does not type in yes or no it writes "invalid input, try again" and restarts from the first "Console.WriteLine()"
Aucun commentaire:
Enregistrer un commentaire