好文档 - 专业文书写作范文服务资料分享网站

中南大学软件体系结构实验5 结构型和行为型设计模式实验

天下 分享 时间: 加入收藏 我要投稿 点赞

public class Button { /** @pdOid a8c78204-5ede-4b5d-8a6c-728613a3904c */ private Switch i; /** @param switch * @pdOid 4d49a447-614e-4c2b-b065-f6a6a3ed53d0 */ public void setSwitch(Switch a) { // TODO: implement i = a; } /** @pdOid 3d47aa4d-415a-40f6-8b46-14acf3a6d039 */ public void click() { // TODO: implement i.execute(); } } public class Client { public static void main(String args[]){ Button button1,button2,button3,button4; Switch switch1,switch2,switch3,switch4; Light light1 = new Light(); Fanner fanner = new Fanner(); button1 = new Button(); button2 = new Button(); button3 = new Button(); button4 = new Button(); switch1 = new FannerOpenSwitch(); switch2 = new FannerCloseSwitch(); switch3 = new LightOpenSwitch(); switch4 = new LightCloseSwitch(); 21

} } switch1.setFanner(fanner); switch2.setFanner(fanner); switch3.setLight(light1); switch4.setLight(light1); button1.setSwitch(switch1); button2.setSwitch(switch2); button3.setSwitch(switch3); button4.setSwitch(switch4); button1.click(); button2.click(); button3.click(); button4.click(); /*********************************************************************** * Module: Fanner.java * Author: ct * Purpose: Defines the Class Fanner ***********************************************************************/ import java.util.*; /** @pdOid cbdbef4a-f8f3-4f17-bc74-11a4b2e5c0f8 */ public class Fanner { /** @pdOid 7aef0cb5-2180-452e-be04-3066aec8ccb6 */ public void open() { // TODO: implement System.out.println(\风扇打开\ } /** @pdOid 3773ee82-63bf-491b-9370-414e9f10819f */ public void close() { // TODO: implement System.out.println(\风扇关闭\ 22

} } /*********************************************************************** * Module: FannerCloseSwitch.java * Author: ct * Purpose: Defines the Class FannerCloseSwitch ***********************************************************************/ import java.util.*; /** @pdOid 6b7b50cd-6c45-43ed-9f09-c4cd172dedda */ public class FannerCloseSwitch extends Switch { /** @pdOid 6ee55f51-a4a0-41da-9781-a822e71780e8 */ private Fanner fanner; public void setFanner(Fanner fanner){ this.fanner = fanner; } /** @pdOid fc34aaa6-c71e-44d7-923e-04e003f7a562 */ public void execute() { // TODO: implement fanner.close(); } } /*********************************************************************** * Module: FannerOpenSwitch.java * Author: ct * Purpose: Defines the Class FannerOpenSwitch ***********************************************************************/ import java.util.*; 23

/** @pdOid d20dabce-44a2-4da8-8033-90f1f67e34d7 */ public class FannerOpenSwitch extends Switch { /** @pdOid 6087bc78-5be9-4d90-ae09-93e6f6060838 */ private Fanner fanner; public void setFanner(Fanner fanner){ this.fanner = fanner; } /** @pdOid f63c7833-5801-49a1-b7eb-00659b2c543a */ public void execute() { // TODO: implement fanner.open(); } } /*********************************************************************** * Module: Light.java * Author: ct * Purpose: Defines the Class Light ***********************************************************************/ import java.util.*; /** @pdOid 8c3bd8ea-c761-466d-9c46-f5172c60126e */ public class Light { /** @pdOid fe4c531a-fb5b-4688-bed5-73e661d1a056 */ public void open() { // TODO: implement System.out.println(\电灯打开\ } /** @pdOid 4075dc22-f423-482e-9800-cfa5d6c7e7f6 */ 24

public void close() { // TODO: implement System.out.println(\电灯关闭\ } } /*********************************************************************** * Module: LightCloseSwitch.java * Author: ct * Purpose: Defines the Class LightCloseSwitch ***********************************************************************/ import java.util.*; /** @pdOid bd09fc94-4e0f-49b3-9958-a0355c95e856 */ public class LightCloseSwitch extends Switch { /** @pdOid 47dda79d-ce1b-4ae7-aaad-5387ae21238d */ private Light light; public void setLight(Light light){ this.light = light; } /** @pdOid e77b9a55-fccf-497b-8528-2c6011398805 */ public void execute() { // TODO: implement light.close(); } } /*********************************************************************** * Module: LightOpenSwitch.java * Author: ct 25

中南大学软件体系结构实验5 结构型和行为型设计模式实验

publicclassButton{/**@pdOida8c78204-5ede-4b5d-8a6c-728613a3904c*/privateSwitchi;/**@paramswitch*@pdOid4d49a447-614e-4c2b-b065-f6a6a3ed53d0*/publicvoidsetSwit
推荐度:
点击下载文档文档为doc格式
6k08424u1392i2p9mdgc
领取福利

微信扫码领取福利

微信扫码分享