Difference between revisions of "UpdateScoreWithPenalty"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with " private static void UpdateScoreWithPenalty(ref int PlayerScore, string PlayerTiles, Dictionary<char, int> tileDictionary) { for (int Count = 0; Cou...")
 
Line 1: Line 1:
 +
<syntaxhighlight lang=csharp>
 
         private static void UpdateScoreWithPenalty(ref int PlayerScore, string PlayerTiles, Dictionary<char, int> tileDictionary)
 
         private static void UpdateScoreWithPenalty(ref int PlayerScore, string PlayerTiles, Dictionary<char, int> tileDictionary)
 
         {
 
         {
Line 6: Line 7:
 
             }
 
             }
 
         }
 
         }
 +
</syntaxhighlight>
  
 
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.
 
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.

Revision as of 12:17, 14 November 2017

        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.