JAVA Head First 系列 面向对象经典 StartBuzz.pptVIP

  • 6
  • 0
  • 约5.02千字
  • 约 33页
  • 2016-04-08 发布于江西
  • 举报

JAVA Head First 系列 面向对象经典 StartBuzz.ppt

JAVA Head First 系列 面向对象经典 StartBuzz.ppt

5. Starbuzz Coffee fee system * Constructing a drink order with Decorators-my third attempt The customer wants Mocha, so we create a Mocha object and wrap it around the DarkRoast. Mocha对象是个包装品。它的类型映射了它所包装的对象的类型。也就是说要把包装品设计成和要包装的类一样的类型。在此,就是Beverage。 因此Mocha也有Cost方法,并且通过多态,我们可以把任何添加了Mocha的Beverage仍然看作Beverage,因为Mocha本身也是Beverage。 5. Starbuzz Coffee fee system * Constructing a drink order with Decorators-my third attempt The customer also wants Whip, so we create a Whip decorator and wrap Mocha with it. Whip is a decorator, so it also mirrors DarkRoast’s type and includes a cost() method. So, a

文档评论(0)

1亿VIP精品文档

相关文档