public static Santa GetInstance() { if (_instance == null) { _instance = new Santa(); } return(_instance); }
private static void GenerateGift(object order) { if (!(order is GiftOrder actualOrder)) { throw new ArgumentException(); } Goblin goblin = new Goblin(); actualOrder.Gift = goblin.Create(actualOrder); Santa.GetInstance().ReadyOrders.Add(actualOrder); }
static void Main(string[] args) { int childAmnount = 100; int outputAmnount = 20; Console.WriteLine("Generating {0} children that wish gifts from Santa.", childAmnount); for (int i = 0; i < childAmnount; i++) { Director.ConstructChild(Builder); var child = Builder.GetChild(); var order = new GiftOrder(child, GetRandomGiftType(), GetRandomGiftColor()); Santa.GetInstance().EnqueueGift(order); ChildList.Add(child); } Console.WriteLine("Santa orders all gifts at once from gift maker."); Santa.GetInstance().OrderGiftsFromGiftMaker(); Console.WriteLine("We are waiting for Christmas...\n"); WaitForChristmas(); Console.WriteLine("HOHOHOOO, it's Christmas so all gifts are delivered.\r\n"); Santa.GetInstance().ItsChristmasTime(); OutputTableWithFirstEntries(outputAmnount); }