【正确答案】正确答案:(1)ticket.printlnvoice() (2)super.printlnvoice() (3)super.printlnvoice() (4)new HeadDecorator(new FootDecorator(t)) (5)new HeadDecorator(new FootDecorator(null))
【答案解析】解析:本题考查装饰(Decorator)模式的基本概念和应用。 装饰模式属于结构型设计模式,其设计意图是动态地给一个对象添加一些额外的职责。就增加功能而言,装饰模式比生成子类更加灵活。装饰模式的结构如图6-2所示。
