设计模式 装饰模式 半透明模式
求助大佬,设计模式立面的装饰模式里面有个半透明装饰模式 我想问下 为什么半透明不能实现二次装饰?
我自己的理解: 因为虽然是具体装饰类的对象,但是具体装饰类传入的是抽象构件类对象,而具体装饰类也是间接继承自抽象构件类的呀,而且我代码也试过了成功的
package DecoratorPattern; public class MainClient { public static void main(String[] args) { Component component=new Window(); ScrollBarDecorator componentDecorator=new ScrollBarDecorator(component); Component component2=new BlackBorderDecorator(componentDecorator); component2.display(); } }