コード例 #1
0
        static void Main(string[] args)
        {
            var darkRoast = new DarkRoast();

            var milk     = new Milk(darkRoast);
            var soybeans = new Soy(milk);

            var milk2     = new Milk(soybeans);
            var totalCost = milk2.Cost();

            Console.WriteLine(Math.Round(totalCost, 2));
            Console.WriteLine(milk2.Description);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Beverage beverage = new Espresso();

            Console.WriteLine(beverage.getDescription()
                              + " $" + beverage.cost());

            Beverage beverage2 = new DarkRoast();

            beverage2 = new Mocha(beverage2);
            beverage2 = new Mocha(beverage2);
            Console.WriteLine(beverage2.getDescription()
                              + " $" + beverage2.cost());

            Console.ReadLine();
        }