JAVA设计模式初探之装饰者模式(三)

2014-11-24 00:07:52 · 作者: · 浏览: 2
tuce = new Lettuce(humburger); System.out.println(lettuce.getName()+" 价钱:"+lettuce.getPrice()); Chilli chilli = new Chilli(humburger); System.out.println(chilli.getName()+" 价钱:"+chilli.getPrice()); Chilli chilli2 = new Chilli(lettuce); System.out.println(chilli2.getName()+" 价钱:"+chilli2.getPrice()); } }

输出

鸡腿堡  价钱:10.0  
鸡腿堡 加生菜  价钱:11.5  
鸡腿堡 加辣椒  价钱:10.0  
鸡腿堡 加生菜 加辣椒  价钱:11.5  


作者:jason0539

微博:http://weibo.com/2553717707

博客:http://blog.csdn.net/jason0539(转载请说明出处)