Difference between revisions of "GetChoice"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with "private static string GetChoice() { string Choice; Console.WriteLine(); Console.WriteLine("Either:"); Console.WriteLine...")
 
m (Describe what the return choice dos.)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 +
<syntaxhighlight lang="c#">
 
private static string GetChoice()
 
private static string GetChoice()
 
         {
 
         {
Line 15: Line 16:
 
             return Choice;
 
             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 sure the number is uppercase for a reason.
+
</syntaxhighlight>
 +
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.

Latest revision as of 13:29, 14 November 2017

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.