其他分享
首页 > 其他分享> > 类适配器模式

类适配器模式

作者:互联网

package com.life.design.adaper.classadapter;

public interface IVoltage5V {
    public int output5V();
}
package com.life.design.adaper.classadapter;

public class Voltage220V {
    public int output220V() {
        int src = 220;
        System.out.println("电压=" + src + "伏");
        return src;
    }
}
package com.life.design.adaper.classadapter;

public class VoltageAdapter extends Voltage220V implements IVoltage5V {

    @Override
    public int output5V() {
        int srcV = output220V();
        int dstV = srcV / 44 ;
        return dstV;
    }
}

 

标签:life,int,适配器,模式,design,adaper,classadapter,public
来源: https://www.cnblogs.com/tsai-87/p/16167182.html