diff --git a/notes/pics/decorator-cost.png b/notes/pics/decorator-cost.png new file mode 100644 index 00000000..e85670ba Binary files /dev/null and b/notes/pics/decorator-cost.png differ diff --git a/notes/设计模式 - 装饰.md b/notes/设计模式 - 装饰.md index cf952924..f26318d0 100644 --- a/notes/设计模式 - 装饰.md +++ b/notes/设计模式 - 装饰.md @@ -14,9 +14,9 @@ 设计不同种类的饮料,饮料可以添加配料,比如可以添加牛奶,并且支持动态添加新配料。每增加一种配料,该饮料的价格就会增加,要求计算一种饮料的价格。 -下图表示在 DarkRoast 饮料上新增新添加 Mocha 配料,之后又添加了 Whip 配料。DarkRoast 被 Mocha 包裹,Mocha 又被 Whip 包裹。它们都继承自相同父类,都有 cost() 方法,外层类的 cost() 方法调用了内层类的 cost() 方法。 +下图对应后面的代码:HouseBlend 饮料先被 Mocha 包裹,Mocha 又被 Milk 包裹。它们都继承自相同父类,都有 cost() 方法,外层类的 cost() 方法调用了内层类的 cost() 方法。 -