设计模式(一)之适配器模式
来源:互联网 发布:莎莎源码网 编辑:程序博客网 时间:2024/05/29 10:28
被适配的类:
public class Adaptee { public void specificMethod(){ System.out.println("三脚插头"); }}
适配接口
public interface AppleInterface { public void phoneInterface();}
适配器
public class Adapter implements AppleInterface { private Adaptee adaptee; public Adapter(Adaptee adaptee) { this.adaptee = adaptee; } @Override public void phoneInterface() { adaptee.specificMethod(); }}
参照类
public class Linghtning implements AppleInterface { @Override public void phoneInterface() { System.out.println("Linghtning."); }}
调用者
public class Consumer { public static void main(String[] args) { // 适配到三脚插头 AppleInterface linghtning = new Adapter(new Adaptee()); linghtning.phoneInterface(); // 只是自己 linghtning = new Linghtning(); linghtning.phoneInterface(); }}
0 0
- 设计模式(一)之适配器模式
- 设计模式之接口型模式(一)----适配器模式
- 每天一设计模式之适配器模式
- C++设计模式之适配器模式(一)
- 设计模式<一>适配器模式
- 设计模式<一>适配器模式
- 设计模式之--适配器模式(adapter)
- 设计模式之Adapter(适配器模式)
- 设计模式之适配器(Adapter)模式
- 设计模式之--适配器模式(adapter)
- 设计模式之适配器模式(Adapter)
- 设计模式之--适配器模式(adapter)
- 设计模式之适配器模式(Adapter)
- 设计模式之--适配器模式(adapter)
- 设计模式之Adapter(适配器)模式
- 设计模式之适配器模式(Adapter)
- 设计模式之(Adapter)适配器模式
- 设计模式之适配器模式(Adapter)
- LoadLibrary加载库失败,getlasterror = 193.
- Android源码学习(4)在Ubuntu11.04上编译Android
- 使用LwIP回调编程实现paho开源MQTT库的移植
- 关于centos中的/etc/sudoers文件中的权限设定
- 如何学习mysql
- 设计模式(一)之适配器模式
- Android源码学习(5)Android编译系统之envsetup.sh
- git报错fatal: HTTP request failed
- C/C++赋值中的退化规则
- Nginx Http负载均衡
- POJ 1190 生日蛋糕
- 如何使用AFNetworking进行上传图片
- 安卓实习期间整理知识点(十二)
- JSONModel解析数据成Model