示例#1
0
        static void Main(string[] args)
        {
            var coffeeWithMilk      = new CoffeeWithMilk(new Coffee(), 3);
            var coffeeWithChocolate = new CoffeeWithChocolate(new Coffee(), 7);

            var coffeeWithChocolateAndMilk = new CoffeeWithChocolate(coffeeWithMilk, 7);

            Console.WriteLine("Total for coffee with milk: " + coffeeWithMilk.GetPrice());
            Console.WriteLine("Total for coffee with chocolate: " + coffeeWithChocolate.GetPrice());
            Console.WriteLine("Total for coffee with milk + chocolate: " + coffeeWithChocolateAndMilk.GetPrice());
        }
示例#2
0
        static void Main(string[] args)
        {
            ICoffee espressoCoffee = new EspressoCoffee();

            Console.WriteLine($"Order: {espressoCoffee.GetDescription()}, " +
                              $"price calculating: {espressoCoffee.Cost()}");

            ICoffee filteredCoffee = new FilteredCoffee();

            Console.WriteLine($"Order: {filteredCoffee.GetDescription()}, " +
                              $"price calculating: {filteredCoffee.Cost()}");

            Console.WriteLine("-------------------------");
            Console.WriteLine("--------Condiment--------");

            ICoffee filteredCoffeeWithMilk = new CoffeeWithMilk(new FilteredCoffee());

            Console.WriteLine($"Order: {filteredCoffeeWithMilk.GetDescription()}, " +
                              $"price calculating: {filteredCoffeeWithMilk.Cost()}");

            ICoffee espressoCoffeeWithMilk = new CoffeeWithMilk(new EspressoCoffee());

            Console.WriteLine($"Order: {espressoCoffeeWithMilk.GetDescription()}, " +
                              $"price calculating: {espressoCoffeeWithMilk.Cost()}");

            ICoffee filteredCoffeeWithChocolate = new CoffeeWithChocolate(new FilteredCoffee());

            Console.WriteLine($"Order: {filteredCoffeeWithChocolate.GetDescription()}, " +
                              $"price calculating: {filteredCoffeeWithChocolate.Cost()}");

            ICoffee espressoCoffeeWithChocolate = new CoffeeWithChocolate(new EspressoCoffee());

            Console.WriteLine($"Order: {espressoCoffeeWithChocolate.GetDescription()}, " +
                              $"price calculating: {espressoCoffeeWithChocolate.Cost()}");

            Console.WriteLine("-------------------------");
            Console.WriteLine("--------Condiment--------");

            ICoffee espressoCoffeeWithChocolateAndMilk =
                new CoffeeWithChocolate(new CoffeeWithMilk(new EspressoCoffee()));

            Console.WriteLine($"Order: {espressoCoffeeWithChocolateAndMilk.GetDescription()}, " +
                              $"price calculating: {espressoCoffeeWithChocolateAndMilk.Cost()}");

            ICoffee filteredCoffeeWithChocolateAndMilk =
                new CoffeeWithChocolate(new CoffeeWithMilk(new FilteredCoffee()));

            Console.WriteLine($"Order: {filteredCoffeeWithChocolateAndMilk.GetDescription()}, " +
                              $"price calculating: {filteredCoffeeWithChocolateAndMilk.Cost()}");
        }