GetScoreForWord

From TRCCompSci - AQA Computer Science
Revision as of 12:48, 14 November 2017 by Larkin (talk | contribs) (Created page with " private static int GetScoreForWord(string Word, Dictionary<char, int> TileDictionary) { int Score = 0; for (int Count = 0; Count < Word...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
       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 section of code will use a 'for' loop in order to calculate the score