装饰者模式
2016-09-09 20:23:35 0 举报
深入浅出设计模式--装饰者模式
作者其他创作
大纲/内容
Whip
Beverage beverage
getDescription() cost()
HouseBlend
cost()
Component
methodA()methodB()//其他方法
ConcreteDecoratorB
Component wrappedObjObject newState
Decaf
装饰者类继承组件抽象类,得到正确的类型,仍然是抽象类
Espresso
组件类通常是抽象类,可单独使用也可被装饰者包起来使用
Decorator
Milk
ConcreteComponent
DarkRoast
CondimentDecorator
getDescription()
Beverage
description
getDescription() cost()//其他有用的方法
Mocha
ConcreteDecoratorA
Component wrappedObj
methodA()methodB()newBehavior()//其他方法
Soy
具体组件类
具体装饰者类的行为来自装饰者和具体组件类
0 条评论
下一页