Difference between revisions of "If a player presses enter without typing a word it is an invalid move"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
Line 14: Line 14:
 
                 if (Choice == "")  
 
                 if (Choice == "")  
 
                 {
 
                 {
                     continue;
+
                     Console.WriteLine("You inputted a word with no letters, this is not a good option!");
 +
                    Console.ReadLine();
 +
                    break;
 
                 }  
 
                 }  
 
             }
 
             }

Revision as of 14:13, 14 November 2017

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 == "") 
                {
                    Console.WriteLine("You inputted a word with no letters, this is not a good option!");
                    Console.ReadLine();
                    break;
                } 
            }
        }
* 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