hottub.hpp
来自「一个类似遥控器的源码程序。可以有多种功能」· HPP 代码 · 共 60 行
HPP
60 行
#ifndef _HEAD_FIRST_DESIGN_PATTERNS_COMMAND_REMOTE_HOT_TUB_HPP_
#define _HEAD_FIRST_DESIGN_PATTERNS_COMMAND_REMOTE_HOT_TUB_HPP_
#include "Remote.hpp"
namespace HeadFirstDesignPatterns {
namespace Command {
namespace Remote {class Hottub { private: bool on; private: int temperature; public: Hottub() : on(false), temperature(0) { } public: virtual void turnOn() { on = true; } public: virtual void turnOff() { on = false; } public: virtual void bubblesOn() { if (on) { std::cout << "Hottub is bubbling!" << std::endl; } } public: virtual void bubblesOff() { if (on) { std::cout << "Hottub is not bubbling" << std::endl; } } public: virtual void jetsOn() { if (on) { std::cout << "Hottub jets are on" << std::endl; } } public: virtual void jetsOff() { if (on) { std::cout << "Hottub jets are off" << std::endl; } } public: virtual void setTemperature(int temperature) { this->temperature = temperature; } public: virtual void heat() { temperature = 105; std::cout << "Hottub is heating to a steaming 105 degrees" << std::endl; } public: virtual void cool() { temperature = 98; std::cout << "Hottub is cooling to 98 degrees" << std::endl; }};} // namespace Remote
} // namespace Command
} // namespace HeadFirstDesignPatterns#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?