コード例 #1
0
        public Gift Create(GiftOrder giftOrder)
        {
            Gift gift = new Gift
            {
                Color = giftOrder.Color
            };

            gift.GiftType = (GiftTypeState)Activator.CreateInstance(giftOrder.GiftType, gift);
            return(gift);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: Santa.cs プロジェクト: levinjoller/Christmas
 public void EnqueueGift(GiftOrder order)
 {
     this.EnqueuedOrders.Add(order);
 }