UpdateScoreWithPenalty

From TRCCompSci - AQA Computer Science
Revision as of 14:35, 14 November 2017 by C.Potts (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
        private static void UpdateScoreWithPenalty(ref int PlayerScore, string PlayerTiles, Dictionary<char, int> tileDictionary)
        {
            for (int Count = 0; Count < PlayerTiles.Length; Count++)
            {
                PlayerScore = PlayerScore - tileDictionary[PlayerTiles[Count]];
            }
        }

The UpdateScoreWithPenalty they use a for loop to update the score. In the "for (int Count = 0; Count < PlayerTiles.Length; Count++)" increases the value of count by 1. In "PlayerScore = PlayerScore - tileDictionary[PlayerTiles[Count]];" this finds the value of the 'player tiles' from the 'tileDictionary' and takes them away from the 'player score' to get the final sum of that round.