当前位置: 首页 > news >正文

广东省住房城乡建设厅官方网站东营新闻最新消息

广东省住房城乡建设厅官方网站,东营新闻最新消息,网站建设文字教程,软件开发工具的基本功能有哪些一、引入 Object Oriented Adapters 二、XX 模式 aka#xff1a;Wrapper (包装器) 2.1 Intent 意图 Convert the interface of a class into another interface clients expect. 将一个类的接口转换成客户希望的另外一个接口. 作为两个不兼容的接口之间的桥梁 适配器模式使…一、引入 Object Oriented Adapters 二、XX 模式 akaWrapper (包装器) 2.1 Intent 意图 Convert the interface of a class into another interface clients expect. 将一个类的接口转换成客户希望的另外一个接口. 作为两个不兼容的接口之间的桥梁 适配器模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作 2.2 Applicability 适用性 You want to use an existing class, and its interface does not match the one you need.you want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don’t necessarily have compatible interfaces.(object adapter only仅对象适配器) you need to use several existing subclasses, but it’s impractical to adapt their interface by subclassing every one. 需要使用几个现有的子类但是通过对每个子类进行子类化来适配它们的接口是不切实际的。 An object adapter can adapt the interface of its parent class. 对象适配器可以适配其所有子类父类的接口. 2.3 类图 类适配器多继承not for java、多实现对象适配器关联依赖组合 Client: Collaborates with objects conforming to the Target interface. 与符合目标接口的对象进行协作Target: Defines the domain-specific interface that Client uses, It should be an interface. 定义 Client 使用的特定领域的接口它应该是一个接口Adaptee: Defines an existing interface that needs adapting, could be an interface, or abstract class, or class. 定义需要适配的现有接口Adaptee 可以是接口、抽象类或类Adapter: Adapts the interface of Adaptee to the Target interface. 适配 Adaptee 的接口到目标接口 2.4 实例鸭子与火鸡 鸭子与火鸡 If it walks like a duck and quacks like a duck, then it might be a turkey wrapped with a duck adapter 如果它像鸭子一样走路那么它可能是一只带着鸭子适配器的火鸡 鸭子 public interface Duck {public void quack();public void fly(); }public class MallardDuck implements Duck {public void quack() {System.out.println(Quack);}public void fly() {System.out.println(Im flying);} } 火鸡 public interface Turkey {public void gobble();public void fly(); }public class WildTurkey implements Turkey {public void gobble() {System.out.println(Gobble gobble);}public void fly() {System.out.println(Im flying a short distance);} }火鸡适配器适配火鸡接口 public class TurkeyAdapter implements Duck {Turkey turkey;public TurkeyAdapter(Turkey turkey) {this.turkey turkey;}public void quack() {turkey.gobble();}public void fly() {for (int i 0; i 5; i) {turkey.fly();}} }public class DuckTestDrive {public static void main(String[] args) {MallardDuck duck new MallardDuck();WildTurkey turkey new WildTurkey();Duck turkeyAdapter new TurkeyAdapter(turkey);System.out.println(The Turkey says...);turkey.gobble();turkey.fly();System.out.println(\nThe Duck says...);testDuck(duck);System.out.println(\nThe TurkeyAdapter says...);testDuck(turkeyAdapter);}static void testDuck(Duck duck) {duck.quack();duck.fly();} }鸭子适配器适配鸭子 public class DuckAdapter implements Turkey {Duck duck;Random rand;public DuckAdapter(Duck duck) {this.duck duck;rand new Random();}public void gobble() {duck.quack();}public void fly() {if (rand.nextInt(5) 0) {duck.fly();}} }public class TurkeyTestDrive {public static void main(String[] args) {MallardDuck duck new MallardDuck();Turkey duckAdapter new DuckAdapter(duck);for (int i 0; i 10; i) {System.out.println(The DuckAdapter says...);duckAdapter.gobble();duckAdapter.fly();}} }2.5 实例适配枚举到迭代器 The early collections types (Vector, Stack, Hashtable, and a few others) implement a method elements(), which returns an Enumeration. Adapting an Enumeration to an Iterator. TargetIteratorAdapteeEnumerationAdapterEnumerationIterator SuppressWarnings(unchecked) public class EnumerationIterator implements Iterator {Enumeration enumeration;public EnumerationIterator(Enumeration enumeration) {this.enumeration enumeration;}public boolean hasNext() {return enumeration.hasMoreElements();}public Object next() {return enumeration.nextElement();}public void remove() {throw new UnsupportedOperationException();} }public class EnumerationIteratorTestDrive {SuppressWarnings(unchecked)public static void main (String args[]) {// Vector v new Vector(Arrays.asList(args));Vector v new Vector(Arrays.asList(A, B, C, E, F, G));Iterator iterator new EnumerationIterator(v.elements());while (iterator.hasNext()) {System.out.println(iterator.next());}} }以迭代器形式遍历枚举。
http://www.hkea.cn/news/14548029/

相关文章:

  • 郑州人才网站海拉尔建设局网站
  • 网站首页一般做多大网站建设需要的资质
  • 凡科网多页网站怎样做宿迁明远建设有限公司网站
  • 做自媒体的网站名字效果图网址
  • 二手商品网站开发背景wordpress如何使用dplayer
  • 设计风格网站怎么查询自己的商标
  • 打开网页出现网站建设中百度优化怎么做
  • 网站制作教程视频中小企业网络组建
  • 电子商务网站建设要多少钱wordpress mu常见问题解答
  • 小程序公众号网站开发网站设计步骤
  • 福田建网站费用中小企业信息服务平台
  • 苏州市城乡和建设局网站首页商机网创业好项目
  • 上海专门做培训的网站湖南建筑信息网
  • 如何利用微信进行企业网站推广怎么推广网站
  • 药厂网站建设南宁西乡塘区网站建设
  • 怎样在阿里巴巴做网站wordpress安装插件要求ftp
  • 给别人做网站挣钱服装网站建设环境分析
  • 建立网站需要多少钱多少钱28湖南岚鸿wordpress附件下载
  • 怎么开跨境电商网店seo课程培训机构
  • 酒店房产网站建设做网站商家
  • 东莞市纺织服装学校大型网站怎么做优化
  • 济南企业自助建站网络美工是干啥的
  • python做的网站如何打开杭州下城区建设局网站
  • 视频相亲网站开发成本编程如何自学
  • 汉寿做网站的公司家庭 wordpress
  • 免费网站模板 怎么用考研资料找微信hyhyk1推广可以
  • 网站开发应用价值建设部网站监理注销查询
  • 怎么建立企业网站php做二手商城网站源码
  • 做黑网站微信公众号接口开发
  • 域名和网站编程培训网站