设计模式-适配器模式
来源:互联网 发布:vscode 函数参数提示 编辑:程序博客网 时间:2024/04/28 11:58
package com.fish;// 三相插座接口public interface ThreePlugIf {// 使用三相电流供电public void powerWithThree();}
package com.fish;public class GBTwoPlug {// 使用二相电流供电public void powerWithTwo() {System.out.println("使用二相电流");}}
package com.fish;public class NoteBook {private ThreePlugIf plug;public NoteBook(ThreePlugIf plug) {this.plug = plug;}// 使用插座充电public void charge() {plug.powerWithThree();}public static void main(String[] args) {GBTwoPlug two = new GBTwoPlug();ThreePlugIf three = new TwoPlugAdapter(two);NoteBook nb = new NoteBook(three);nb.charge();}}
package com.fish;public class TwoPlugAdapter implements ThreePlugIf {private GBTwoPlug plug;@Overridepublic void powerWithThree() {System.out.println("通过转化");plug.powerWithTwo();}public TwoPlugAdapter(GBTwoPlug plug) {this.plug = plug;}}
大神文献
0 0
- 设计模式:适配器模式
- 设计模式------适配器模式
- 设计模式:适配器模式
- 设计模式---适配器模式
- 设计模式 适配器模式
- 设计模式 - 适配器模式
- 设计模式--适配器模式
- 设计模式-适配器模式
- 设计模式------适配器模式
- 设计模式---适配器模式
- 设计模式- 适配器模式
- 设计模式 - 适配器模式
- 设计模式:适配器模式
- 适配器模式--设计模式
- 设计模式 - 适配器模式
- 设计模式-适配器模式
- 设计模式---适配器模式
- 设计模式-适配器模式
- 基本修饰符
- 关于用户密码的简单加密(DES+MD5)与复杂加密(自己想的)
- iOS 动画效果
- c++:批量把数据写入同一文件夹下不同文件
- 发送队列的默认队列策略 (linux网络子系统学习 第十一节 )
- 设计模式-适配器模式
- iOS8定位
- 绕过XSS过滤规则 : Web渗透测试高级XSS教程
- Android Studio优化配置
- getResourceAsStream的用法
- linux下中文乱码的问题
- C#实现 word、pdf、ppt 转为图片
- xamarin ios read txt file
- Windows Java环境搭建