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
    请按任意键继续. . .

  • 相关阅读:
    【独家】K8S漏洞报告 | 近期bug fix解读
    idou老师教你学Istio 29:Envoy启动流程
    idou老师教你学Istio 28:istio-proxy check 的缓存
    idou老师教你学Istio :5分钟简析Istio异常检测
    idou老师教你学Istio 27:解读Mixer Report流程
    idou老师教你学Istio 26:如何使用Grafana进行可视化监控
    idou老师教你学Istio 25:如何用istio实现监控和日志采集
    idou老师教你学Istio 24:如何在Istio使用Prometheus进行监控
    idou老师教你学Istio 23 : 如何用 Istio 实现速率限制
    idou老师教你学Istio 22 : 如何用istio实现调用链跟踪
  • 原文地址:https://www.cnblogs.com/zhangyunlin/p/6167955.html
Copyright © 2011-2022 走看看