GetChoice

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
private static string GetChoice()
        {
            string Choice;
            Console.WriteLine();
            Console.WriteLine("Either:");
            Console.WriteLine("     enter the word you would like to play OR");
            Console.WriteLine("     press 1 to display the letter values OR");
            Console.WriteLine("     press 4 to view the tile queue OR");
            Console.WriteLine("     press 7 to view your tiles again OR");
            Console.WriteLine("     press 0 to fill hand and stop the game.");
            Console.Write("> ");
            Choice = Console.ReadLine();
            Console.WriteLine();
            Choice = Choice.ToUpper();
            return Choice;
        }

This block of code is giving the user a choice of what they want to do, it displays the 4 options the user has in a neat way and then waits for the user to choose one of the options. It also makes it all uppercase so if the player types in a word it will be made capital so no issues with cases can arise. It will then return the choice to the method so the rest of the program can use the choice value.