面向对象系统分析与设计_观察者模式.ppt
《面向对象系统分析与设计_观察者模式.ppt》由会员分享,可在线阅读,更多相关《面向对象系统分析与设计_观察者模式.ppt(16页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、06 一月 2023Neusoft Computer Science and Technology Department copy right1OO System Analysis&Design【The Observer Pattern】06 一月 2023Neusoft Computer Science and Technology Department copy right2Weather Monitoring overviewStats ForecastCurrent pulls data WeatherDataobject displays Weather StationOur cli
2、ent providesWhat we implementinternet06 一月 2023Neusoft Computer Science and Technology Department copy right3What is WeatherData object?lIt knows how to talk to the physical Weather Station,to get updated data.(we dont care for this process.)lIt then updates its displays for the three different disp
3、lay elements.gets data updates o它提供了三个方法(get开头),可以分别取得实时的温度、湿度和大气压力,还有一个MeasurementsChanged()方法,当任何天气状况发生变化的时候,这个方法都会自动被触发,当前这个方法只是一个空函数,扩展的代码还需要我们自己去扩充。06 一月 2023Neusoft Computer Science and Technology Department copy right41 客户提供了获取实时的天气状况的方法2 MeasurementsChanged()方法会在天气状况变化时被自动调用。3 系统要实现三种显示模式,分别
4、显示天气状况、天气统计和天气预测,而且这些显示的信息必须跟当前最新的天气状况实时同步。4 系统还必须支持在显示方式上的扩展性,而且使用者可以任意添加和移除不同的显示模式。06 一月 2023Neusoft Computer Science and Technology Department copy right5o/伪代码opublic class WeatherDatao o/实例化显示设备(省略)opublic void MeasurementsChanged()oofloat temp=getTemperature();/取得温度ofloat humidity=getHumidity()
5、;/取得湿度ofloat pressure=getPressure();/取得气压ocurrentConditionsDisplay.update(temp,humidity,pressure);/同步显示当前天气状况ostatisticsDisplay.update(temp,humidity,pressure);/同步显示天气统计信息oforecastDisplay.update(temp,humidity,pressure);/同步显示天气预报信息oo06 一月 2023Neusoft Computer Science and Technology Department copy rig
6、ht606 一月 2023Neusoft Computer Science and Technology Department copy right7Our job is:lTo create an app that uses the WheatherData object to update three displays.06 一月 2023Neusoft Computer Science and Technology Department copy right8The kernel of the problemWeatherData object to update if you requ
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 面向 对象 系统分析 设计 观察者 模式
限制150内