很久之前写的了,命名不规范还请见谅
public class adaptee {
public void show() {
System.out.println("被适配者,有特殊功能");
}
}
package 设计模式八大考题.对象适配器模式;
public class adapter implements target {
private adaptee adaptee;
public adapter( adaptee adaptee){
this.adaptee=adaptee;
}
public void get() {
adaptee.show();
}
}
package 设计模式八大考题.对象适配器模式;
public interface target {
public void get() ;
}
package 设计模式八大考题.对象适配器模式;
public class client {
public static void main(String[] args) {
target target=new adapter(new adaptee());
target.get();
}
}