简单遥控器
来源:互联网 发布:斐波那契数列c语言for 编辑:程序博客网 时间:2024/04/27 16:03
#include<cstdio>#include<iostream>using namespace std;class Command{public: virtual void execute() {}};class Light{public: void On() { cout<<"Light on"<<endl; } void Off() { cout<<"Light off"<<endl; }};class LightOnCommand :public Command{private: Light *light;public: LightOnCommand(Light *light) { light=light; } void execute() { light->On(); }};class LightOffCommand :public Command{private: Light *light;public: LightOffCommand(Light *light) { light=light; } void execute() { light->Off(); }};class SimpleRemoteControl{public: Command *slot; SimpleRemoteControl() {} void setCommand(Command *command) { slot=command; } void buttonWasPresseed() { slot->execute(); }};int main(){ SimpleRemoteControl *remote =new SimpleRemoteControl(); Light *light=new Light(); LightOnCommand *lightOn = new LightOnCommand(light); remote->setCommand(lightOn); remote->buttonWasPresseed();}
阅读全文
0 0
- 简单遥控器
- js模拟键盘或遥控器操作(简单版)
- android 空调遥控器——简单发送内容
- 又说遥控器
- IR 遥控器
- 修遥控器
- 手机遥控器
- 捕魚機遥控器
- 打魚機遥控器
- 麻将遥控器
- 麻将遥控器
- 遥控器APP
- nyoj543遥控器
- 2416 遥控器
- NYOJ:遥控器
- 红外遥控器
- 魔杖遥控器
- Pocket PC 电视遥控器
- 「游族杯」上海市高校程序设计邀请赛暨华东师范大学第九届 ECNU Coder 程序设计竞赛 (重现) Problem D. 萝莉理论计算机科学家
- nodejs service 循环ep
- 数组指针,指针数组
- ATS磁盘读取初始化流程:
- Struts2 控制文件上传下载
- 简单遥控器
- 【Codeforces 803 C. Maximal GCD】
- 基于 Vue 的直播播放器实战
- 微擎分页
- 反射
- Windows Server 2012 系统群集
- js的垃圾回收机制
- 去重删除重复的行,只留一条
- 对象的初始化