1603体系结构实验报告三_第1页
1603体系结构实验报告三_第2页
1603体系结构实验报告三_第3页
1603体系结构实验报告三_第4页
1603体系结构实验报告三_第5页
已阅读5页,还剩51页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

实验3设计模式实验4133:设计性4:研究性123:其它33:专 一、实验目熟练使用PowerDesigner和任意一种面象编程语言实现几种常见的结构型设计模式二、实验内、、某公司为新开发的智能控制与管理提供了一键备份功能,通过该功能可以将原本在中的通信录、歌曲等资料全部拷贝到移动介质(MMCSD卡)中。在实现过程中需要与多个已有的类进行交互,例如、、、管理类管理类等,为了降低系统的耦合度,试使用外观模式来设计并编程模拟实现该、某信息系统需要提供一个数据处理和报表显示模块,该模块可以不同类型的文件中的数据并将数据转换成XML格式,然后对数据进行统计分析,最后以报表方式来显示在某应用中需要记录业务方法的调用日志,在不修改现有业务类的基础上为每一个类提供一个日志记录类,在类中输出日志,例如在业务方法method()调用之前10:10:10输出“方法method()调用成功否则输出“方法method()调用失败。在类中调用真实在一个中已用户和游客的权限不同,已的用户拥有发帖、修改自己的保护来设计该权限管理模块,绘制类图并编程模拟实现。某公司欲开发一个基于Windows平台的公告板系统。系统提供一个主菜单 类的add 法增加菜单项。菜单项的主要方法是click(),每一个菜单项包含一个抽象命令类,具体命令 mand(新建命令), 命令类具有一个execute()方法用于调用公告板系统界面类(BoardScreen)的open()create()、 Item类与BoardScreen类的耦合度降某实时需要提供如下功能:当者所的某支价格变化某公司开发一机房系统,果机房到一指定温,温度感器(Throenso)(auonLigh(fce、器Annucar)(aar(ecryDor)(oen热门(nsuadDor)(coe选择一种合适的设计模式来设计该处理结合场景绘制相应的类图并编程模拟音效(SoundEffect)、场景(Scene)、角色(Role)等对象进行参数设置。为了节约系统资源并且保证对象状态的一致性,在运行时,用户只能打开唯一的一个管理器界面。为了让场景呈现更加真的效果在某FPS中可以对场景(Scene)的光照效果等进行渲染(Rendering)。考虑到系统的可扩展性,开发可以实现表面渲染(SurfaceRendering)和体渲染(VolumeRendering)等算法,也可以调用一些已有的渲染引擎(Render三、实验要结合实例,正确无误地绘制外观模式、模式、职责链模式、命令模式、观察者四、实验步结合实例使用PowerDesigner绘制外观模式实例结构图并用面象编程语言实现结合实例使用PowerDesigner绘制模式实例结构图并用面象编程语言实现结合实例使用PowerDesigner绘制职责链模式实例结构图并用面象编程语言实结合实例使用PowerDesigner绘制命令模式实例结构图并用面象编程语言实现结合实例使用PowerDesigner绘制观察者模式实例结构图并用面象编程语言实结合实例使用PowerDesigner绘制策略模式实例结构图并用面象编程语言实现五、实验结//TimesNewRoman或Arial,字号为五号,如classShpackagepublicclassPicture{publicvoidCopy(){System.out.println("Pictureiscopide}}packagepublicclassMusicpublicvoid{System.out.println("Musiciscopide}}packagepublicclassMessagepublicvoid{System.out.println("Messageiscopide}}packagepublicclassContectpublicvoid{System.out.println("Contectiscopide}}packageimportpublicclassFacadeContectcontect=newContect();Messagemessage=newMessage();Musicmusic=newMusic();Picturepicture=newPicture();publicvoidCopy(){}}packagepackagepublicclassClientpublicstaticvoidmain(String[]args)//TODOAuto-generatedmethodstubFacadefacade=newFacade();}}packagepackagepublicclassClientpublicstaticvoidmain(String[]args)//TODOAuto-generatedmethodstub Facade=newXMLFacade(); Facade=newNotXMLFacade();}}packageFacadevoidexcute()}packagepublicclassXMLFacade privateReadFilereadFile=newprivateData ysisdata ysis=newData privateShowReportshowReport=newShowReport();publicvoidexcute(){System.out.println("xml"); }}packagepublicclassNotXMLFacadeextends Facade{privateReadFilereadFile=newReadFile();privateTransToXMLtransToXML=newTransToXML();privateData ysisdata ysis=newData privateShowReportshowReport=newShowReport();publicvoidexcute(){System.out.println("xml文件,需要转换"); }}packagepublicclassReadFilepublicvoid{System.out.println("readfile}}packagepublicclassTransToXMLpublicvoid{System.out.println("transtoxml}}packagepublicclass ysispublic { ysisdata}}packagepublicpublicclassShowReportpublicvoid{System.out.println("showreport}}packagepackageimportpublic Log void}packagepublicclassLogImplpublicvoidLogRecord()//TODOAuto-generatedmethodstub}}packageimportimportpublicclassLogProxy publicLogProxy(Log) //TODOAuto-generatedconstructor}publicvoidInvokMethodTime()//TODOAuto-generatedmethodSimpleDateFormatdateFormat=newSimpleDateFormat("yyyy-MM-ddSystem.out.println("method()被调用,调用时间为:"+dateFormat.format(newDate()));}publicvoidLogRecord()//TODOAuto-generatedmethod}catch(Exceptione)//TODO:handleexceptionSystem.out.println("method()被调用失败");}}}packagepublicclassClientpublicstaticvoidmain(String[]args)////TODOAuto-generatedmethod Log=newLogImpl();LogProxylogProxy=newLogProxy( }}package classUser voidpost(String voidmodifyInfo(String voidmodifyPost(String voidviewPost(String}packagepublicclassRealUserextendsUserpublicvoidpost(StringuserId){System.out.println(userId发布了一篇帖子");}publicvoidmodifyInfo(StringuserId){System.out.println(userId修改了个人信息");}publicvoidmodifyPost(StringuserId){System.out.println(userId修改了帖子内容");}publicvoidviewPost(StringuserId){System.out.println(userId浏览了一篇帖子");}}packagepublicclassUserProxyextendsUserprivateRealUserrealUser=newpublicvoidpost(StringuserId)}publicvoidmodifyInfo(StringuserId)}publicvoidmodifyPost(StringuserId){if}publicvoidviewPost(StringuserId){}}packagepublicbooleanvalidate(StringuserId){returnuserId.equals("grizz");}}<?xmlversion="1.0"package import importjavax.xml.parsers. importjavax.xml.parsers.ParserConfigurationException;publicclassXMLUtilpublicstaticObject{try =NodeListnodeList= Nodenode=nodeList.item(0).get Stringuser=Classc=Class.forName(user);returnc.newInstance();}catch(Exceptione){}return}}packagepublicclassClientpublicstaticvoidmain(String[]args)Useruser=(User)XMLUtil.getBean();}}}packagepackagepublicclassCheckFilterextendsDataFilterpublicvoidprocessData(Stringdata){System.out.println("对data进行数据校验");}}packagepublicclassTypeFilterextendsDataFilterpublicvoidprocessData(Stringdata)System.out.println("对data进行数据类型转换");}}package classDataFilterprotectedDataFilterpublicvoidprocessData(Stringdata)//TODO:}publicvoidsetSuccessor(DataFiltersuccessor){this.successor=successor;}}packagepublicclassEncodeFilterextendsDataFilterpublicvoidprocessData(Stringdata){System.out.println("publicvoidprocessData(Stringdata){System.out.println("对data进行字符编码转换");}}packagepublicclassClientpublicstaticvoidmain(String[]args)DataFilterencodeFilter=newEncodeFilter();DataFiltertypeFilter=newTypeFilter();DataFiltercheckFilter=new}}publicpublicclassSwitchprivateCommandpublicvoidpress(){}publicvoid mand(Commandcommand){mand=command;}} classCommand void}public mandextendsCommandprivateFanfan=newpublicvoidexecute(){}}publicclassFanprivatebooleanstate=publicvoidswitchState(){state=!state;if}}publicclassFanprivatebooleanstate=publicvoidswitchState(){state=!state;if}}public mandextendsCommand ightlight=newpublicvoidexecute(){}}publicclassFanprivatebooleanstate=publicvoidswitchState(){state=!state;if}} import importjavax.xml.parsers. importjavax.xml.parsers.ParserConfigurationException;publicclassXMLUtilpublicstaticObject{try = NodeListnodeList= Nodenode=nodeList.item(0).get Stringcommand=Classc=Class.forName(command);returnc.newInstance();}catch(Exceptione){}return}}<?xmlversion="1.0" publicclassClientpublicstaticvoidmain(String[]args)Switchsw=newCommandcommand=(Command)XMLUtil.getBean();}}importimportpublic{ Items=newpublicList<} publicvoid}Item)} classCommand void}public ItemprivateCommandpublicvoidclick()}publicvoid mand(Commandcommand){mand=command;}}public mandextendsCommand ScreenboardScreen=newpublicvoidexecute(){}} public mandextendsCommand ScreenboardScreen=newpublicvoidexecute(){}}public mandextendsCommand ScreenboardScreen=newpublicvoidexecute(){}}publicclassBoardScreenpublicvoidopen(){System.out.println("open()");}publicvoidcreate(){System.out.println("create()");}publicvoidedit(){System.out.println("edit()");}} import importjavax.xml.parsers. importjava.util.ArrayList;importpublicclassXMLUtilpublicstaticList<Object>{List<Object>objects=newArrayList<>(); = NodeListnodeList for(inti=0;i<nodeList.getLength();{Nodenode=nodeList.item(i).get Stringcommand=node.getNodeValue().trim();Classc=Class.forName(command);}return}catch(Exception{}return}}<?xmlversion="1.0" importpublicclassClientpublicstaticvoidmain(String[]args)= List<Object>commands=XMLUtil.getBeans();for(inti=0;i<commands.size();i++){ Item= }for {}}}importimportpublicclassShareprotectedList<ShareHolder>shareHolders=newprotecteddoubleprotecteddoublepublicShareHolderpublicvoidaddShareHolder(ShareHoldershareHolder){}publicvoidremoveShareHolder(ShareHoldershareHolder){}publicvoidnotify(doublenewPrice)}}publicclassConcreteShareextendsSharepublicvoidnotify(doublenewPrice)if((newPrice-oldPrice)/oldPrice<0.05)for(ShareHoldershareHolder:shareHolders){}}}packagepublicinterfaceShareHoldervoidupdate(double}publicclassConcreteShareHolderimplementsShareHolderprivatedoubleprivateStringpublicvoidupdate(doublenewPrice){price=newPrice;System.out.println("通知"+name+ 的新价格为"+}publicConcreteShareHolder(Stringname){=name;}}publicclassClientpublicpublicstaticvoidmain(String[]args)Shareshare=newConcreteShare();share.oldPrice=10;ShareHoldergrizz=newConcreteShareHolder("grizz");ShareHolderpanda=newConcreteShareHolder("panda");share.newPrice=10.1;share.newPrice=15;}}importpublicclassMonitorprotectedList<Equipment>equipments=newpublicEquipmentpublicvoidaddEquipment(Equipmentequipment){}publicvoidremoveEquipment(Equipmentequipment){}publicvoidnotifyEquipments()//TODO:}}publicclassThermosensorextendsMonitorpublicvoidnotifyEquipments()for(Equipmentequipment:{}}}publicinterfaceEquipmentvoid}publicclassAnnunciatorEquipmentextendsAnnunciatorimplementsEquipmentpublicvoidreact(){}}publicclassAnnunciatorpublicvoidalarm() }}publicclassCautionLightEquipmentextendsCautionLightimplementsEquipmentpublicvoidreact(){}}publicclassCautionLightpublicvoidflicker(){}}publicclassInsulatedDoorEquipmentextendsInsulatedDoorimplementsEquipmentpublicvoidreact(){}}publicclassInsulatedDoorpublicvoidclose()}}publicclassSecurityDoorEquipmentextendsSecurityDoorimplementsEquipmentpublicvoidreact(){}}publicclassSecurityDoorpublicvoidopen()}}package import importjavax.xml.parsers. importjava.util.ArrayList;importpublicclassXMLUtilpublicstaticList<Object>{List<Object>objects=newArrayList<>(); = NodeListnodeList for(inti=0;i<nodeList.getLength();{Nodenode=nodeList.item(i).get Stringcommand=node.getNodeValue().trim();Classc=Class.forName(command);}return}catch(Exception{}return}}<?xmlversion="1.0" importimportpublicclassClientpublicstaticvoidmain(String[]args)Monitormonitor=newThermosensor();List<Object>equipments=XMLUtil.getBeans();for(Objectequipment:equipments){}}}publicclassPhotographprivateFilterpublicvoidprocess(){}publicvoidsetFilter(Filter{this.filter=}}publicinterfaceFiltervoid}publicclassMonochromaticFilterimplementsFilterpublicvoidfilter() }}publicclassNostalgicFilterimplementsFilterpublicvoidfilter() }}publicclassBlackWhiteFilterimplementsFilterpublicvoidfilter() }}<?xmlversion="1.0" import import publicclassXMLUtilpublicstaticObject{try =NodeListnodeList= Nodenode=nodeList.item(0).get Stringcommand=ClassClassc=Class.forName(command);returnc.newInstance();}catch(Exceptione){}return}}publicclassClientpublicstaticvoidmain(String[]args)Photographphotograph=newPhotograph();Filterfilter=(Filter)XMLUtil.getBean();}}publicpublicclassGameManagerprivatevolatilestaticGameManagerins

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论