适配器模式
//源类
public class Chazuo {
public void output() {
System.out.println("插座可能输出220v或者110v");
}
}
public interface Adapter {
public void output5v();
}
public class Phone extends Chazuo implements Adapter{
public void charging() {
output5v();
System.out.println("正在用5v电压充电");
}
@Override
public void output5v() {
this.output();
System.out.println("转换成5v");
}
public static void main(String[] args) {
Phone phone = new Phone();
phone.charging();
}
}