首页 > 代码库 > DecoratorPattern

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();
		}
	} 
	
}

  

DecoratorPattern