版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、2020年10月31日星期六,Neusoft Computer Science and Technology Department copy right,1,OO System Analysis /取得温度 float humidity = getHumidity(); /取得湿度 float pressure = getPressure(); /取得气压 currentConditionsDisplay.update(temp, humidity, pressure); /同步显示当前天气状况 statisticsDisplay.update(temp, humidity, pressure
2、); /同步显示天气统计信息 forecastDisplay.update(temp, humidity, pressure); /同步显示天气预报信息 ,2020年10月31日星期六,Neusoft Computer Science and Technology Department copy right,6,2020年10月31日星期六,Neusoft Computer Science and Technology Department copy right,7,Our job is:,To create an app that uses the WheatherData object t
3、o update three displays.,2020年10月31日星期六,Neusoft Computer Science and Technology Department copy right,8,The kernel of the problem,WeatherData object,to update if you require,displays,publishers,subscribers,to deliver if you subscribe,subject object,observer objects,to notify if you observe,2020年10月3
4、1日星期六,Neusoft Computer Science and Technology Department copy right,9,The Observer Pattern,The Observer Pattern defines a one-to-many relationship between objects so that when one object changes state, all of its dependents are notified and updated automatically.,2020年10月31日星期六,Neusoft Computer Scie
5、nce and Technology Department copy right,10,Class diagram for Observer Pattern,Each subject can have many observers,update() will be called when the Subjects state changes.,These methods will be called When to register as observers , remove themselves from Being observers, or update all the observer
6、s whenever state changes.,2020年10月31日星期六,Neusoft Computer Science and Technology Department copy right,11,To develop app from the interface,Subject(被观察的对象接口) 规定ConcreteSubject的统一接口; 每个Subject可以有多个Observer; ConcreteSubject(具体被观察对象) 维护对所有具体观察者的引用的列表; 状态发生变化时会发送通知给所有注册的观察者。 Observer(观察者接口) 规定ConcreteOb
7、server的统一接口; 定义了一个update()方法,在被观察对象状态改变时会被调用。 ConcreteObserver(具体观察者) 维护一个对ConcreteSubject的引用; 特定状态与ConcreteSubject同步; 实现Observer接口,通过update()方法接收ConcreteSubject的通知。,2020年10月31日星期六,Neusoft Computer Science and Technology Department copy right,12,顺序图,2020年10月31日星期六,Neusoft Computer Science and Techno
8、logy Department copy right,13,2020年10月31日星期六,Neusoft Computer Science and Technology Department copy right,14,Designing the Weather Station,Exercise: A Spring Tour plan,Spring tour plan manage system need to maintain a collection of the participants Notify all members of the information about the plan Each member have their own arrival at the point of collection,2020年10月31日星期六,Neusoft Computer Science and Technology Department copy right,15,2020年10月31日星期六,Neusoft Computer
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026辽阳市城市地下管线探测行业市场现状供需分析及投资评估规划分析研究报告
- 2026中国VR-AR技术应用市场调研及趋势分析报告
- 2026中国城市共同配送试点政策实施效果评估报告
- 2026钠离子电池产业化进度与替代潜力深度分析报告
- 2026中国液体化工区域物流中心选址与辐射效应研究
- 2026骨质疏松治疗药物市场消费行为与竞争策略报告
- 2026年浙江省中考语文真题卷(含答案与解析)
- 铁路防洪应急演练考试题库2026
- 绿色建筑物业运行方案
- 小学生创新作业研究报告
- 2026届高考语文考向核心卷含答案(全国二卷)
- 中石油招聘历年笔试真题(完整版含答案解析)
- 2026年迪庆州德钦县国投(集团)公司及下属二级公司工作人员招聘(25人)笔试备考题库及答案详解
- 2026年人教版新教材数学五年级上册全套单元、期中、期末测试题及答案(共10套题)
- 2026年广东省中考语文现代文《我心中的刘禹锡》批注式阅读
- 2026年(完整版)计算机控制技术试卷及答案
- 【新教材】人教版(2024)七年级上册美术全册教案
- 初中生物实验题题库及答案
- 高考英语近5年(2020-2025)真题高频词汇短语800词(完整版可打印)
- 220kV变电站电气工程专业监理实施细则
- 2026年河北省高中学业水平考试物理试卷试题(含答案)
评论
0/150
提交评论