您的位置:首页 > 其它

对象适配器模式

2016-06-16 10:45 197 查看
public class Source{

public void method1(){

System.out.println("this is a method1");

}

}

public interface Targetable{

public void method1();

public void method2();

}

public class Wrapper implemenets Targetable{

private Source source;

public Targetable(Source source){

this.source = source

}

@Override

public void method1(){

System.out.println("this is original method1");

}

@Override

public void method2(){

System.out.println("this is the method2");

}

}

public class TestWrapper{

public static void main(){

Source source = new Source();

Targetable targeable = new Wrapper(source);

targetable.method1();

targetable.method2();

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  对象适配器