static void Main(string[] args) { IceCream iceCream = new Vanilla(); iceCream = new Sprinkle(iceCream); iceCream = new Fudge(iceCream); Console.WriteLine(iceCream.Cost()); Console.ReadKey(); }
static void Main(string[] args) { IBeverage coffee = new Espresso(); Console.WriteLine($"{coffee.Description}: £{coffee.Cost}"); coffee = new DarkRoast(); coffee = new Mocha(coffee); coffee = new Mocha(coffee); coffee = new Whip(coffee); Console.WriteLine($"{coffee.Description}: £{coffee.Cost}"); //or, decorating decorators ... coffee = new Vanilla(new Mocha(new Mocha(new DarkRoast()))); Console.WriteLine($"{coffee.Description}: £{coffee.Cost}"); Console.ReadKey(); }