Difference between revisions of "Make the letters K V X Y Z Q 4 points instead of the current 3"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with "private static void CreateTileDictionary(ref Dictionary<char, int> TileDictionary) { int[] Value1 = { 0, 4, 8, 13, 14, 17, 18, 19 }; int[] Valu...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
At the moment the subroutine CreateTileDictionary looks like this:
 +
 +
<syntaxhighlight lang=Csharp>
 
private static void CreateTileDictionary(ref Dictionary<char, int> TileDictionary)
 
private static void CreateTileDictionary(ref Dictionary<char, int> TileDictionary)
 
         {
 
         {
Line 24: Line 27:
 
             }
 
             }
 
         }
 
         }
 +
</syntaxhighlight>
  
 
The arrays Value1, Value2 and Value3 list the numbers of the letters with the scores 1, 2 and 3 respectively. Add a new array, Value4, and move the letters K (10), V (21) and Y (24) to this array. Make sure to remove these numbers from the Value3 array.
 
The arrays Value1, Value2 and Value3 list the numbers of the letters with the scores 1, 2 and 3 respectively. Add a new array, Value4, and move the letters K (10), V (21) and Y (24) to this array. Make sure to remove these numbers from the Value3 array.
Line 29: Line 33:
 
Add an extra else if into the for loop to include the Value4 array. Set the score to 4.
 
Add an extra else if into the for loop to include the Value4 array. Set the score to 4.
  
 +
<syntaxhighlight lang=Csharp>
 
private static void CreateTileDictionary(ref Dictionary<char, int> TileDictionary)
 
private static void CreateTileDictionary(ref Dictionary<char, int> TileDictionary)
 
         {
 
         {
Line 59: Line 64:
 
             }
 
             }
 
         }
 
         }
 +
</syntaxhighlight>

Latest revision as of 09:39, 14 May 2018

At the moment the subroutine CreateTileDictionary looks like this:

private static void CreateTileDictionary(ref Dictionary<char, int> TileDictionary)
        {
            int[] Value1 = { 0, 4, 8, 13, 14, 17, 18, 19 };
            int[] Value2 = { 1, 2, 3, 6, 11, 12, 15, 20 };
            int[] Value3 = { 5, 7, 10, 21, 22, 24 };
            for (int Count = 0; Count < 26; Count++)
            {
                if (Array.IndexOf(Value1, Count) > -1)
                {
                    TileDictionary.Add((char)(65 + Count), 1);
                }
                else if (Array.IndexOf(Value2, Count) > -1)
                {
                    TileDictionary.Add((char)(65 + Count), 2);
                }
                else if (Array.IndexOf(Value3, Count) > -1)
                {
                    TileDictionary.Add((char)(65 + Count), 3);
                }
                else
                {
                    TileDictionary.Add((char)(65 + Count), 5);
                }
            }
        }

The arrays Value1, Value2 and Value3 list the numbers of the letters with the scores 1, 2 and 3 respectively. Add a new array, Value4, and move the letters K (10), V (21) and Y (24) to this array. Make sure to remove these numbers from the Value3 array.

Add an extra else if into the for loop to include the Value4 array. Set the score to 4.

private static void CreateTileDictionary(ref Dictionary<char, int> TileDictionary)
        {
            int[] Value1 = { 0, 4, 8, 13, 14, 17, 18, 19 };
            int[] Value2 = { 1, 2, 3, 6, 11, 12, 15, 20 };
            int[] Value3 = { 5, 7, 22 };
            int[] Value4 = { 10, 21, 24 };
            for (int Count = 0; Count < 26; Count++)
            {
                if (Array.IndexOf(Value1, Count) > -1)
                {
                    TileDictionary.Add((char)(65 + Count), 1);
                }
                else if (Array.IndexOf(Value2, Count) > -1)
                {
                    TileDictionary.Add((char)(65 + Count), 2);
                }
                else if (Array.IndexOf(Value3, Count) > -1)
                {
                    TileDictionary.Add((char)(65 + Count), 3);
                }
                else if (Array.IndexOf(Value4, Count) > -1)
                {
                    TileDictionary.Add((char)(65 + Count), 4);
                }
                else
                {
                    TileDictionary.Add((char)(65 + Count), 5);
                }
            }
        }