예제 #1
0
        public static void Main(string[] args)
        {
            var coffee = new Coffee();
            var milk   = new Milk(coffee);
            var sugar  = new Sugar(milk);

            Console.WriteLine(sugar.Name + ", price: " + sugar.Price);
        }
예제 #2
0
        static void Main(string[] args)
        {
            ICoffee coffee = new Coffee();

            coffee = new Sugar(coffee);
            coffee = new Sugar(coffee);
            coffee = new Sugar(coffee);
            coffee = new Whipp(coffee);
            coffee = new Milk(coffee);

            Console.WriteLine("Details: " + coffee.GetDetails());
            Console.WriteLine("Cost: " + coffee.GetCost());

            Console.ReadKey();
        }
예제 #3
0
        static void Main(string[] args)
        {
            Beverage beverage = new Coffee();

            beverage = new Milk(beverage);
            beverage = new Sugar(beverage);
            beverage = new Sugar(beverage);

            Console.WriteLine("Description - " + beverage.Description);
            Console.WriteLine("Cost - " + beverage.Cost());
            Console.WriteLine();

            beverage = new Sugar(new Sugar(new Tea()));

            Console.WriteLine("Description - " + beverage.Description);
            Console.WriteLine("Cost - " + beverage.Cost());

            Console.Read();
        }