欢迎来到天天文库
浏览记录
ID:57038715
大小:1.60 MB
页数:22页
时间:2020-07-27
《面向对象系统分析与设计_02_设计模式_入门 策略模式课件.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、OOSystemAnalysis&Design【IntrotoDesignPattern】2021/7/291NeusoftComputerScienceandTechnologyDepartment©2021/7/29NeusoftComputerScienceandTechnologyDepartmentcopyright©2ThegoaloftodayOODesignPrinciple1:?2021/7/29NeusoftComputerScienceandTechnologyDepartmentcopyright©3Alittlebackgro
2、und…Thegameisaduckpondsimulationgamethatshowalargevarietyofduckspeciesswimmingandmakingquackingsounds.2021/7/29NeusoftComputerScienceandTechnologyDepartmentcopyright©4Case:DuckPondSimulationMallard:swim,display,fly,quackRedhead:swim,display,fly,quackRubber:swim,display,---,squea
3、kWooden:swim,display,---,---2021/7/29NeusoftComputerScienceandTechnologyDepartmentcopyright©5Solution:versionprototype2021/7/29NeusoftComputerScienceandTechnologyDepartmentcopyright©6MallardReadheadRubberWoodenDuckSolution:version1swim()display()fly()quack()swim()display()fly()q
4、uack()swim()display()fly()quack()swim()display()fly()quack()swim()display()fly()quack()donothingdonothingsqueakdonothing2021/7/29NeusoftComputerScienceandTechnologyDepartmentcopyright©7MallardReadheadRubberWoodenDuckSolution:version2display()fly()quack()display()fly()quack()disp
5、lay()fly()quack()display()fly()quack()swim()display()fly()quack()QuackBehavoirquack()<>FlyBehavoirfly()<>==2021/7/29NeusoftComputerScienceandTechnologyDepartmentcopyright©8Whythetwoversionisn’tsowell?Theyalldependinheritance!Whatwouldwedo?2021/7/29NeusoftCo
6、mputerScienceandTechnologyDepartmentcopyright©9Arevelationfromhardware:IntegrationfixedIndependenceflexible2021/7/29NeusoftComputerScienceandTechnologyDepartmentcopyright©10IndependenceCardstructureboarddisplaycardinterfacespecssoundcardinterfacespecsdisplaycard1displaycard2disp
7、laycard3soundcard1soundcard2boardAdisplaycard3soundcard3soundcard2boardBsoundcard3displaycard22021/7/29NeusoftComputerScienceandTechnologyDepartmentcopyright©11Duckswim()display()Cardstructure.vs.Duckstructureboarddisplaycardinterfacespecssoundcardinterfacespecsdisplaycard1sound
8、card1boardAdisplaycard3soundcard2boardBsoundcar
此文档下载收益归作者所有