DecoratorPattern(装饰器模式)

/**
 * 装饰者模式
 * @author TMAC-J
 * 总的来说,装饰者模式就是继承的应用
 */
public class DecoratorPattern {
	
	interface Beans{
		void doSomething();
	}
	
	public class MyBean implements Beans{
		@Override
		public void doSomething() {
			System.out.println("doSomething...");
		}
	}
	
	public class DecoratorMyBean extends MyBean{
		public void doMoreThing(){
			System.out.println("doOtherthing...");
			doSomething();
		}
	} 
	
}

  

posted @ 2016-12-27 19:27  麦子TMAC  阅读(152)  评论(0编辑  收藏  举报