using System.Collections.Generic;
public static void Main()
Console.WriteLine("Hello World");
Singleton singleton = Singleton.GetInstance();
Console.WriteLine("All letters");
singleton.GetLetters().ForEach(x => Console.Write(x));
List<string> player1 = singleton.GetTiles(7);
Console.WriteLine("Player1's letters");
player1.ForEach(x => Console.Write(x));
Console.WriteLine("\nSingleton instantance " + singleton.GetHashCode());
Singleton singleton2 = Singleton.GetInstance();
List<string> player2 = singleton2.GetTiles(8);
Console.WriteLine("Player2's letters");
player2.ForEach(x => Console.Write(x));
Console.WriteLine("Singleton instantance" + singleton2.GetHashCode());
private static Singleton firstInstance = null;
static string[] scrabbleLetters = {"a", "a", "a", "a", "a", "a", "a", "a", "a", "b", "b", "c", "c", "d", "d", "d", "d", "e", "e", "e", "e", "e", "e", "e", "e", "e", "e", "e", "e",
"f", "f", "g", "g", "g", "h", "h", "i", "i", "i", "i", "i", "i", "i", "i", "i", "j", "k", "l", "l", "l", "l", "m", "m", "n", "n", "n", "n", "n", "n",
"o", "o", "o", "o", "o", "o", "o", "o", "p", "p", "q", "r", "r", "r", "r", "r", "r", "s", "s", "s", "s", "t", "t", "t", "t", "t", "t",
"u", "u", "u", "u", "v", "v", "w", "w", "x", "y", "y", "z"};
private List<string> letterList = new List<string>(scrabbleLetters);
public static Singleton GetInstance()
if(firstInstance == null)
firstInstance = new Singleton();
public List<string> GetLetters()
return firstInstance.letterList;
public List<string> GetTiles(int howManyTiles)
List<string> letters = new List<string>();
for(int i = 0; i < howManyTiles; i++)
letters.Add(firstInstance.letterList.First());
firstInstance.letterList.RemoveAt(0);