⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 remotecontrol.hpp

📁 一个类似遥控器的源码程序。可以有多种功能
💻 HPP
字号:
#ifndef	_HEAD_FIRST_DESIGN_PATTERNS_COMMAND_REMOTE_CONTROL_HPP_
#define _HEAD_FIRST_DESIGN_PATTERNS_COMMAND_REMOTE_CONTROL_HPP_

#include "Remote.hpp"

namespace HeadFirstDesignPatterns {
namespace Command {
namespace Remote {//// This is the invoker//class RemoteControl {	private: Command* onCommands[7];	private: Command* offCommands[7];	public: RemoteControl() {		Command* noCommand = new NoCommand();		for (int i = 0; i < 7; i++) {			onCommands[i] = noCommand;			offCommands[i] = noCommand;		}	}	public: virtual void setCommand(int slot, Command* onCommand, Command* offCommand) {		onCommands[slot] = onCommand;		offCommands[slot] = offCommand;	}	public: virtual void onButtonWasPushed(int slot) {		onCommands[slot]->execute();	}	public: virtual void offButtonWasPushed(int slot) {		offCommands[slot]->execute();	}	public: virtual std::string toString() {		std::stringstream stringBuff;		stringBuff << "\n------ Remote Control -------\n" << std::endl;		for (int i = 0; i < 7; i++) {			stringBuff  << "[slot " << i << "] "						<< typeid(*onCommands[i]).name()						<< "    "						<< typeid(*offCommands[i]).name()						<< std::endl;		}		return stringBuff.str();	}};} // namespace Remote
} // namespace Command
} // namespace HeadFirstDesignPatterns#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -