zoukankan      html  css  js  c++  java
  • Head First设计模式C++实现Command模式

    定义:

      命令模式将“请求”封装成对象,以便试用不同的请求,队列或者日志来参数化其他对象。命令模式也可支持可撤销的操作。

    UML图:

    UML-Command

    程序实现:

    程序输出:

    ----------- Remote Control ----------
    [slot 0]LightOnCommand          LightOffCommand
    [slot 1]LightOnCommand          LightOffCommand
    [slot 2]CeillingFanOnCommand          CeillingFanOffCommand
    [slot 3]StereoOnWithCDCommand          StereoOffCommand
    [slot 4]NoCommand          NoCommand
    [slot 5]NoCommand          NoCommand
    [slot 6]NoCommand          NoCommand

    Living Roomlight is on
    Living Roomlight is off
    Kitchenlight is on
    Kitchenlight is off
    Living Room ceiling fan is on high
    Living Room ceiling fan is off
    Living Room Stereo volume set to 11
    Living Room stereo is set for CD input
    Living Room stereo is on
    Living Room stereo is on
    Living Room stereo is set for CD input
    Living Room Stereo volume set to 11
    Living Room stereo is off
    请按任意键继续. . .

  • 相关阅读:
    Labshare 生物信息学在线软件集锦
    为什么要给单个细胞测序?
    两行代码解决Android9.0 CLEARTEXT communication not supported: [ConnectionSpec...
    Android 网络框架:Retrofit2一篇就够了(2020-4-23)
    Android通用流行框架大全
    base64图片裁剪空白区域
    常用的几款抓包工具
    Message: 'chromedriver' executable needs to be in PATH
    nginx+lua+redis做访问鉴权
    win10安装markdownpad2打开显示错误this view has crashed!
  • 原文地址:https://www.cnblogs.com/zhangyunlin/p/6167955.html
Copyright © 2011-2022 走看看