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

家居企业网站建设效果网站建设平台官网要点有哪些

家居企业网站建设效果,网站建设平台官网要点有哪些,网站规划包括哪些方面,seo关键词快速获得排名文章目录一、引入二、代理模式,Prototype Pattern2.1 Intent 意图2.2 Applicability 适用性2.3 类图2.4 应用实例:使用下划线或消息框展示字符串2.4 应用实例:JDK java.lang.Object java.lang.Cloneable一、引入 二、代理模式,Pr…

文章目录

      • 一、引入
      • 二、代理模式,Prototype Pattern
        • 2.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 box
  • However, 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 HashMap<String, 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.yayakq.cn/news/144580/

相关文章:

  • 网站开发工具介绍阿里巴巴网站开发是谁
  • 公司网站建设推进表百度搜索网站的图片
  • 化学试剂网站建设做网站销售好吗
  • 免费收录网站推广云南外贸建站推广
  • 始兴建设局网站徐州建设工程监理
  • 广州哪家做网站兼职建设网站
  • 网站建设开发公司有哪些网站小程序app开发
  • 东莞电商网站公司网站建设的完整流程包括
  • wordpress 电子商务网站seo的方法
  • 网站设计大小wordpress 可视化表格
  • 如何设计网站风格网站开发 附加协议
  • 南宁网站建设公司排名南昌优化排名推广
  • 免费北京网站建设上海加盟网网站建设
  • 网站优化具体怎么做免费的网站托管
  • 网站广告是文化事业建设费天晴创艺网站建设百度小程序
  • 周到的网站建站自适应网站开发文字大小如何处理
  • 外贸网站运营推广百度引流推广哪家好
  • 牛商网建设的食品网站电影点播网站开发费用
  • 北京装饰公司设计手机优化不到80怎么办
  • 最好的完全免费开源企业网站广告公司网站设计方案
  • 如何免费注册网站域名网站上微信的链接怎么做
  • 网站设置始终请求电脑版湖南人文科技学院怎么样
  • asp网站怎么连接数据库广州营销策划公司排名
  • 名表网站做网站不推广有效果吗
  • 西安企业建站价格wordpress建影视网站
  • 一级域名的免费网站豌豆荚应用商店
  • 做网站云服务器装系统一元云购网站建设教程
  • 建网站最低需要多少钱苏州网站开发公司有哪些
  • 桂林北站离哪个景区近网站的建设与维护步骤
  • 品牌网站建设 杭州网络销售是什么工作内容