/**
适配器模式
两种完全不同的事物联系到一起
**/
public class Phone{
public static final int V = 220;
private VoltageAdapter adapter;
public void charge(){
adapter.changeVoltage();
}
public void setVoltageAdapter(VoltageAdapter adapter){
this.adapter = adapter;
}
}
public class VoltageAdapter{
public void changeVoltage(){
System.out.println("正在充电。。。");
System.out.println("原始电压" + phone.V + "V");
System.out.println("经过变压器变压后" + (phone.V - 200) + "V");
}
}