If a player presses enter without typing a word it is an invalid move

From TRCCompSci - AQA Computer Science
Revision as of 15:04, 14 November 2017 by AJackson (talk | contribs) (Created page with "<syntaxhighlight lang=csharp> private static void HaveTurn(string PlayerName, ref string PlayerTiles, ref int PlayerTilesPlayed, ref int PlayerScore, Dictionary<char, int> Til...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

<syntaxhighlight lang=csharp> private static void HaveTurn(string PlayerName, ref string PlayerTiles, ref int PlayerTilesPlayed, ref int PlayerScore, Dictionary<char, int> TileDictionary, ref QueueOfTiles TileQueue, List<string> AllowedWords, int MaxHandSize, int NoOfEndOfTurnTiles)

       {
           Console.WriteLine();
           Console.WriteLine(PlayerName + " it is your turn.");
           DisplayTilesInHand(PlayerTiles);
           string NewTileChoice = "2";
           bool ValidChoice = false;
           bool ValidWord = false;
           string Choice = "";
           while (!ValidChoice)
           {
               Choice = GetChoice();
               if (Choice == "") 
               {
                   continue;
               } 

<syntaxhighlight>

* This code demonstrates what would happen if a user was to attempt entering a word that does not exist
* The part of the code used for this function can be found starting line 14, finishing on line 17
* This means that if the user word is equal to nothing, it takes the user back to the choice screen
* This code avoids potential accidents if a misclick occurs