public interface Extends {
void show();
void show2();
}public class SourceObj {
void method() {
System.out.println("父亲方法");
}
}//适配器对象
public class AdapterObject implements Extends{
private SourceObj source;
public AdapterObject(SourceObj source) {
this.source = source;
}
public void method() {
source.method();
}
@Override
public void show() {
// TODO Auto-generated method stub
System.out.println("接口show()");
}@Override
public void show2() {
// TODO Auto-generated method stub
System.out.println("接口show2()");
}
}//+继承关系
public class Adapter extends SourceObj implements Extends{
@Override
public void show() {
// TODO Auto-generated method stub
System.out.println("接口show()");
}@Override
public void show2() {
// TODO Auto-generated method stub
System.out.println("接口show2()");
}
}
//实现与调用
Adapter adapter = new Adapter();
adapter.method();
adapter.show();
adapter.show2();
SourceObj sourceObj = new SourceObj();
AdapterObject aObject = new AdapterObject(sourceObj);
aObject.method();
aObject.show();
aObject.show2();