/// <summary> /// Set the tiles based on the Scrabble Game /// </summary> public ScrabbleGame() { int startingLetter = (char)'A'; int total = 0; //Loop through the letters and determine how many tiles per letter for (int i = startingLetter; i < (startingLetter + 26); i++) { total += ScrabbleLetter.HowManyTiles((char)i); } //Set variable values and instantiate the array m_tilesLeft = total + 2; m_totalTiles = total + 2; m_scrabbleLetters = new ScrabbleLetter[total + 2]; //2 blank tiles! int counter = 0; //use to control the index of the array //Loop through the letters to create the tiles for (int i = startingLetter; i < (startingLetter + 26); i++) { //Loop through the number of tiles for that letter for (int j = 0; j < ScrabbleLetter.HowManyTiles((char)i); j++) { m_scrabbleLetters[counter] = new ScrabbleLetter((char)i); counter++;//always increase the counter! } } //add the two blanks m_scrabbleLetters[counter] = new ScrabbleLetter(' '); counter++; m_scrabbleLetters[counter] = new ScrabbleLetter(' '); }
/// <summary> /// Returns how many tiles in scrabble have the letter. /// </summary> /// <param name="L">The letter.</param> /// <returns></returns> public static int HowManyTiles(char L) { ScrabbleLetter s = new ScrabbleLetter(L); return(s.NumberOfLetters); }