Create a method to list the words available within a given hand

From TRCCompSci - AQA Computer Science
Revision as of 15:31, 14 November 2017 by Charley (talk | contribs) (Created page with "The option "See available words with this hand." is added to the player's options in GetChoice(). private static string GetChoice() { string Choice;...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The option "See available words with this hand." is added to the player's options in GetChoice().

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.WriteLine("     press 3 to see available words with this hand.");
           Console.Write("> ");
           Choice = Console.ReadLine();
           Console.WriteLine();
           Choice = Choice.ToUpper();
           return Choice;
       }

The following code is added to the choices in Have Turn:

else if (Choice == "3")

               {
                   for (int i = 0; i < AllowedWords.Count; i++)
                   {
                       bool wordintiles = CheckWordIsInTiles(AllowedWords[i], PlayerTiles);
                       if (wordintiles == true)
                       {
                           Console.WriteLine(AllowedWords[i]);
                       }
                   }
               }