mirror of
https://github.com/huihut/interview.git
synced 2025-12-18 21:14:38 +03:00
Design mode code comments are changed to English
https://github.com/huihut/interview/pull/73
This commit is contained in:
@@ -8,43 +8,43 @@
|
||||
#include "abstraction.h"
|
||||
#include <iostream>
|
||||
|
||||
// 拉链式开关
|
||||
// Zipper switch
|
||||
class PullChainSwitch : public ISwitch
|
||||
{
|
||||
public:
|
||||
PullChainSwitch(IElectricalEquipment *ee) : ISwitch(ee) {}
|
||||
|
||||
// 用拉链式开关打开电器
|
||||
// Turn on the equipment with a zipper switch
|
||||
virtual void On() override
|
||||
{
|
||||
std::cout << "Switch on the equipment with a pull chain switch." << std::endl;
|
||||
std::cout << "Turn on the equipment with a zipper switch." << std::endl;
|
||||
m_pEe->PowerOn();
|
||||
}
|
||||
|
||||
// 用拉链式开关关闭电器
|
||||
// Turn off the equipment with a zipper switch
|
||||
virtual void Off() override
|
||||
{
|
||||
std::cout << "Switch off the equipment with a pull chain switch." << std::endl;
|
||||
std::cout << "Turn off the equipment with a zipper switch." << std::endl;
|
||||
m_pEe->PowerOff();
|
||||
}
|
||||
};
|
||||
|
||||
// 两位开关
|
||||
// Two-position switch
|
||||
class TwoPositionSwitch : public ISwitch
|
||||
{
|
||||
public:
|
||||
TwoPositionSwitch(IElectricalEquipment *ee) : ISwitch(ee) {}
|
||||
|
||||
// 用两位开关打开电器
|
||||
// Turn on the equipment with a two-position switch
|
||||
virtual void On() override
|
||||
{
|
||||
std::cout << "Switch on the equipment with a two-position switch." << std::endl;
|
||||
std::cout << "Turn on the equipment with a two-position switch." << std::endl;
|
||||
m_pEe->PowerOn();
|
||||
}
|
||||
|
||||
// 用两位开关关闭电器
|
||||
// Turn off the equipment with a two-position switch
|
||||
virtual void Off() override {
|
||||
std::cout << "Switch off the equipment with a two-position switch." << std::endl;
|
||||
std::cout << "Turn off the equipment with a two-position switch." << std::endl;
|
||||
m_pEe->PowerOff();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user