设计模式笔记之适配器模式(Adapter Pattern)
来源:互联网 发布:飞鹰网络电视安卓 编辑:程序博客网 时间:2024/05/18 03:11
一.概述:
三.测试适配器:
适配器模式将一个对象包装起来改变其接口,装饰者模式将一个对象
包装起来增加新的行为或责任,适配器的意图是将接口转换为不同的接口
适配器模式将一个类的接口,转化成客户期望的另一个接口,适配器让原本接口不兼容的类可以合作无间
二.狼-羊适配器:
public class SheepAdapter implements Sheep { private Wolf wolf; public SheepAdapter(Wolf wolf) { this.wolf = wolf; } @Override public void ho() { wolf.ho(); } @Override public void run() { wolf.run(); }}
三.测试适配器:
Wolf wolf = new Wolf(); Sheep sheep = new SheepAdapter(wolf); sheep.run(); sheep.ho();结果:狼跑狼嚎四。小结:
适配器模式将一个对象包装起来改变其接口,装饰者模式将一个对象
包装起来增加新的行为或责任,适配器的意图是将接口转换为不同的接口
- 设计模式笔记之适配器模式(Adapter Pattern)
- 设计模式之适配器模式(Adapter Pattern)
- 设计模式之适配器模式--- Pattern Adapter
- 适配器设计模式(Adapter Pattern)
- 设计模式笔记9:适配器模式(Adapter Pattern)
- 设计模式学习笔记十一:适配器模式(Adapter Pattern)
- Php设计模式之【适配器模式 Adapter Pattern】
- .Net设计模式之适配器模式(Adapter Pattern)
- 设计模式之六:适配器模式(Adapter Pattern)
- JAVA设计模式之 适配器模式【Adapter Pattern】
- Java设计模式之适配器模式(Adapter Pattern)
- C#设计模式之适配器模式(Adapter Pattern)
- 设计模式(结构型)之适配器模式(Adapter Pattern)
- 设计模式之适配器模式(Adapter Pattern)C++实现
- 思维盛宴之设计模式-适配器模式Adapter Pattern
- 《设计模式解析》读书笔记之Adapter Pattern(适配器模式)
- 设计模式总结之Adapter Pattern(适配器模式)
- Net设计模式实例之适配器模式(Adapter Pattern)
- 笔试 sizeof 字节对齐 结构体
- 在red hat linux 5上安装oracle 11g
- Linux Utils API Reference Guide
- android音乐播放器Service的生命周期分析
- 手机的几种定位方式
- 设计模式笔记之适配器模式(Adapter Pattern)
- NFS
- How to Delete Process Chain Logs in SAP BW?
- 复制互联网——2010全球最值得模仿的230个网站
- VC精确计时(转)
- flex 生命周期学习
- java发送短信
- 固定DIV高度 当内容超出高度时被隐藏
- ActionScript3.0的安全域和应用程序域