Mid From PDF GoF Patterns Gang of Four Patterns

Decorator (CoffeeDecorator):?

  • The CoffeeDecorator class is an abstract class that implements the

ICoffee interface and holds a reference to an ICoffee object. This class

allows us to add additional behavior to the coffee object, but we don't modify

the base class (SimpleCoffee).

public abstract class CoffeeDecorator : ICoffee

protected ICoffee _coffee;

protected CoffeeDecorator(ICoffee coffee) => _coffee = coffee;

public virtual double Cost() => _coffee.Cost();

public virtual string Description() => _coffee.Description();

More from Design Patterns in C#

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details