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

茂名市城市建设档案馆网站有谁做分销网站

茂名市城市建设档案馆网站,有谁做分销网站,中山建设监理有限公司 网站,网上竞价投标流程文章目录一、引入二、代理模式#xff0c;Prototype Pattern2.1 Intent 意图2.2 Applicability 适用性2.3 类图2.4 应用实例#xff1a;使用下划线或消息框展示字符串2.4 应用实例#xff1a;JDK java.lang.Object java.lang.Cloneable一、引入 二、代理模式#xff0c;Pr… 文章目录一、引入二、代理模式Prototype Pattern2.1 Intent 意图2.2 Applicability 适用性2.3 类图2.4 应用实例使用下划线或消息框展示字符串2.4 应用实例JDK java.lang.Object java.lang.Cloneable一、引入 二、代理模式Prototype Pattern 代理模式实现了一个原型接口用于创建当前对象的克隆。 2.1 Intent 意图 Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype. 使用原型实例指定要创建的对象类型并通过克隆此原型来创建新对象 2.2 Applicability 适用性 When a system should be independent of how its products are created, composed, and represented. 当一个系统应该独立于它的产品创建构成和表示时When the classes to instantiate are specified at run-time, for example, by dynamic loading. 当要实例化的类是在运行时刻指定时例如通过动态装载.To avoid building a class hierarchy of factories that parallels the class hierarchy of products. 为了避免创建一个与产品类层次平行的工厂类层次时. (工厂模式介绍)When instances of a class can have one of only a few different combinations of state. 当一个类的实例只能有几个不同状态组合中的一种时. 2.3 类图 Prototype: Declares an interface for cloning itself. 声明一个用于克隆自身的接口ConcretePrototype: Implements an operation for cloning itself. 实现一个克隆自身的操作 2.4 应用实例使用下划线或消息框展示字符串 To show a string with underline or message box: Conventionally, we have to design three different classes to show a string with underline or message boxHowever, we will design too many classes to show different underline or message box styles Prototype public interface Product extends Cloneable {public abstract void use(String s);public abstract Product createClone(); }public class MessageBox implements Product {private char decochar;public MessageBox(char decochar) {this.decochar decochar;}public void use(String s) {int length s.getBytes().length;for (int i 0; i length 4; i) {System.out.print(decochar);}System.out.println();System.out.println(decochar s decochar);for (int i 0; i length 4; i) {System.out.print(decochar);}System.out.println();}public Product clone() {Product p null;try {p (Product) super.clone();} catch (CloneNotSupportedException e) {e.printStackTrace();}return p;} }public class UnderlinePen implements Product {private char ulchar;public UnderlinePen(char ulchar) {this.ulchar ulchar;}public void use(String s) {int length s.getBytes().length;System.out.println(\ s \);System.out.print( );for (int i 0; i length; i) {System.out.print(ulchar);}System.out.println();}public Product clone() {Product p null;try {p (Product) super.clone();} catch (CloneNotSupportedException e) {e.printStackTrace();}return p;} }Manager public class Manager {private HashMap showcase new HashMapString, Product();public void register(String name, Product proto) {showcase.put(name, proto);}public Product create(String protoname) {Product p (Product) showcase.get(protoname);return p.clone();} }ClientDemo public class Main {public static void main(String[] args) {// 准备Manager manager new Manager();UnderlinePen upen new UnderlinePen(~);MessageBox mbox new MessageBox(*);MessageBox sbox new MessageBox(/);manager.register(strong message, upen);manager.register(warning box, mbox);manager.register(slash box, sbox);// 生成Product p1 manager.create(strong message);p1.use(Hello, world.);Product p2 manager.create(warning box);p2.use(Hello, world.);Product p3 manager.create(slash box);p3.use(Hello, world.);} }2.4 应用实例JDK java.lang.Object java.lang.Cloneable java.lang.Object
http://www.hkea.cn/news/14325274/

相关文章:

  • 网站建设玖金手指排名11国外开源建站系统
  • 汝州建站公司网站php源码破解版
  • 临沂科技学校网站建设微网站 小程序 区别
  • 网站建设导航网页制作论文范例
  • 淄博服装网站建设海城做网站
  • 阿里云网站申请用途做网站项目的流程
  • 餐饮网站源码开发区建设集团网站
  • 河南网站排名优化网站 网页制作
  • Asp.net网站开发分析网站空间买卖
  • 一家专门做原型的网站mysql创建WordPress
  • 印度网站域名wordpress跳转
  • 做药品网站有哪些大气手机企业网站
  • 网站布局教程百度推广合作
  • 网站优化顺义案例成都市建设局官方网站
  • 中徽园林建设有限公司网站栾城网站建设
  • 网站提速wordpress vip服务积分
  • 快递物流网站建设开发具备哪些功能韶关做网站的
  • 高级网站设计效果图app下载app开发公司
  • 富民网站建设电脑课程培训零基础
  • 莱州网站建设费用成都企业网站建设 四川冠辰科技
  • 网站建设收费明细网站建设安全方案
  • 长沙做网站要多少钱wordpress 百度文库
  • 做外包胡it网站网站打开很慢怎么回事啊
  • 如何用apache建设网站最新seo视频教程
  • 医院网站建设策划案模板住房和城乡建设部官网查询平台
  • 网站建设及管理工作岗位要求网络公司经营范围写电子商务
  • 用flash做的网站展示wordpress 小工具开发
  • 龙岗网站建设服务岳阳网站建设哪里有
  • 网站 短链接怎么做No商业网站建设
  • 如何做网站方案天津网站推广方法