コード例 #1
0
        static void Main(string[] args)
        {
            SingleItem burger = new SingleItem {
                Description = "Mic Bag Burger", Price = 25
            };
            SingleItem fries = new SingleItem {
                Description = "Curly Braces Fries", Price = 11
            };
            SingleItem drink = new SingleItem {
                Description = "Pepsi Minimum", Price = 16
            };
            SingleItem wrap = new SingleItem {
                Description = "Panel Wrap", Price = 22
            };
            SingleItem shake = new SingleItem {
                Description = "Sharp Shake", Price = 15
            };

            SingleItem[] order =
            {
                burger,
                fries,
                drink,
                wrap,
                shake
            };

            foreach (SingleItem item in order)
            {
                Console.WriteLine(item);
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            IOrderItem burger = new SingleItem {
                Description = "Mic Bag Burger", Price = 25
            };
            IOrderItem fries = new SingleItem {
                Description = "Curly Braces Fries", Price = 11
            };
            IOrderItem drink = new SingleItem {
                Description = "Pepsi Minimum", Price = 16
            };
            IOrderItem wrap = new SingleItem {
                Description = "Panel Wrap", Price = 22
            };
            IOrderItem shake = new SingleItem {
                Description = "Sharp Shake", Price = 15
            };

            IOrderItem order = new GroupItem(
                "Main Order",
                0,
                new GroupItem
                (
                    "Curly Mic Combo",
                    15,
                    burger,
                    fries,
                    drink
                ),
                wrap,
                shake
                );

            Console.WriteLine(order);
        }