UpdateScoreWithPenalty

From TRCCompSci - AQA Computer Science
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.