1, 2, or 3 letter words should incur a penalty

From TRCCompSci - AQA Computer Science
Jump to: navigation, search

You can find this in the section of the code which gets the score for the word

   
     private static int GetScoreForWord(string Word, Dictionary<char, int> TileDictionary)
        {
            int Score = 0;
            for (int Count = 0; Count < Word.Length; Count++)
            {
                Score = Score + TileDictionary[Word[Count]];
            }
            if (Word.Length > 7)
            {
                Score = Score + 20;
            }
            else if (Word.Length > 5)
            {
                Score = Score + 5;
            }

            return Score;
        }

The above code is Before the code has been Changed

   
     private static int GetScoreForWord(string Word, Dictionary<char, int> TileDictionary)
        {
            int Score = 0;
            for (int Count = 0; Count < Word.Length; Count++)
            {
                Score = Score + TileDictionary[Word[Count]];
            }
            if (Word.Length > 7)
            {
                Score = Score + 20;
            }
            else if (Word.Length > 5)
            {
                Score = Score + 5;
            }
            else if (Word.Length <= 3)
            {
                Score = Score - 3;
                Console.WriteLine("The Choice is very short, penalty of -3 points given!");
                Console.ReadLine();
            }
            return Score;
        }

So you can see that the final "Else if" statement has been added which enables the penalty that the exam may actually ask for.