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

子网站建设的好处seo与sem的区别和联系

子网站建设的好处,seo与sem的区别和联系,推动政府门户网站建设,专业做食材网站文章目录 Java 设计模式之备忘录模式概述UML代码实现 Java 设计模式之备忘录模式 概述 备忘录(Memento):在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态。方便对该对象恢复到原先保存的状态。 UML Originnato…

文章目录

  • Java 设计模式之备忘录模式
    • 概述
    • UML
    • 代码实现

Java 设计模式之备忘录模式

概述

  • 备忘录(Memento):在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态。方便对该对象恢复到原先保存的状态。

UML

在这里插入图片描述

  • Originnator:发起者类,指需要被保存状态的对象,负责创建备忘录并恢复状态。
  • Memento:备忘录类,负责存储发起者的内部状态。
  • Caretaker:管理者类,负责保存和管理备忘录,不直接操作备忘录的内容。

代码实现

定义发起者类:

public class TextEditor {private String content;public String getContent() {return content;}public void setContent(String content) {this.content = content;}// 创建备忘录public TextEditorMemento createMemento() {return new TextEditorMemento(content);}// 恢复备忘录public void restoreMemento(TextEditorMemento memento) {this.content = memento.getContent();}@Overridepublic String toString() {return "TextEditor{" +"content='" + content + '\'' +'}';}
}

定义备忘录类:

public class TextEditorMemento {private final String content;public TextEditorMemento(String content) {this.content = content;}public String getContent() {return content;}
}

定义管理类:

public class TextEditorHistory {private final Stack<TextEditorMemento> history = new Stack<>();// 保存状态public void save(TextEditor editor) {history.push(editor.createMemento());}// 撤销操作public void undo(TextEditor editor) {if (!history.isEmpty()) {editor.restoreMemento(history.pop());} else {System.out.println("没有历史数据,不能撤销");}}
}

使用:

public class Client {public static void main(String[] args) {TextEditorHistory history = new TextEditorHistory();TextEditor editor = new TextEditor();// 编辑内容并保存状态editor.setContent("one");history.save(editor);System.out.println(editor);// 编辑内容并保存状态editor.setContent("two");history.save(editor);System.out.println(editor);// 只编辑内容editor.setContent("three");// 第1次撤销操作history.undo(editor);System.out.println("第1次撤销操作后:" + editor);// 第2次撤销操作history.undo(editor);System.out.println("第2次撤销操作后:" + editor);// 第3次撤销操作history.undo(editor);System.out.println("第3次撤销操作后:" + editor);}
}

输出:

TextEditor{content='one'}
TextEditor{content='two'}
第1次撤销操作后:TextEditor{content='two'}
第2次撤销操作后:TextEditor{content='one'}
没有历史数据,不能撤销
第3次撤销操作后:TextEditor{content='one'}
http://www.dtcms.com/wzjs/460323.html

相关文章:

  • 仿政府网站开鲁网站seo不用下载
  • 网站文章页图片不显示北京十大教育培训机构排名
  • 七彩建设发展有限公司官方网站站长统计免费下载
  • html5电影网站如何做苏州seo报价
  • 哪些网站是可以做网络推广的seo算法优化
  • 郑州网站建设培训学校磁力引擎
  • 全国货到付款网站seo推广学院
  • 网站建设培训教程投广告的平台有哪些
  • 快站app官网下载英文seo是什么
  • 武汉企业苏州搜索引擎优化
  • 完全的图片宣传网站怎么做搜索引擎优化包括哪些方面
  • 平面设计十大风格山西seo优化
  • 中山网站建设方案微信引流推广怎么做
  • 荆州网站推广怎么做网站推广的方法有哪些?
  • 大浪网站建设宁波网站推广方案
  • 网站建设网络营销平台 云搜系统互联网推广的好处
  • 用java做的网上购物网站免费的seo
  • 学网站建设需要几年培训学校加盟
  • 网站建设 系统维护东莞百度seo电话
  • 斗鱼网站的实时视频是怎么做的互联网营销师培训课程
  • 无锡网站建设价格费用推广竞价
  • 河南郑州汽车网网站建设北京seo技术
  • 上海著名企业百度搜索引擎优化案例
  • 做赌钱网站网络营销实训总结报告
  • 一个教做网页的网站近期发生的重大新闻
  • 青岛做外贸网站百度小说风云排行榜
  • 建立企业网站选什么好免费seo关键词优化排名
  • 一般做个网站多少钱18款免费软件app下载
  • 男女做的那些事情的网站微信指数怎么看
  • 广州做网站的网络公司网站建设解决方案