Adding State in Decorator Pattern

后端 未结 3 854
眼角桃花
眼角桃花 2021-01-22 09:07

I wonder how to add state to the chain of decorators that will be available to the consumer. Given this simplified model:

abstract class AbstractPizza 
{
    pub         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-22 09:45

    I believe your component Pizza and your abstract decorator PizzaDecorator are supposed to share the same interface, that way each instance of the decorator is capable of the same operations as the core component Pizza.

提交回复
热议问题