2018-07-22 14:50:54 +08:00
|
|
|
//
|
|
|
|
// Created by xiemenghui on 2018/7/21.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef DESIGNPATTERN_REFINED_ABSTRACTION_H
|
|
|
|
#define DESIGNPATTERN_REFINED_ABSTRACTION_H
|
|
|
|
|
|
|
|
#include "abstraction.h"
|
|
|
|
#include <iostream>
|
|
|
|
|
2020-12-16 16:07:24 +08:00
|
|
|
// Zipper switch
|
2018-07-22 14:50:54 +08:00
|
|
|
class PullChainSwitch : public ISwitch
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PullChainSwitch(IElectricalEquipment *ee) : ISwitch(ee) {}
|
|
|
|
|
2020-12-16 16:07:24 +08:00
|
|
|
// Turn on the equipment with a zipper switch
|
2018-07-22 14:50:54 +08:00
|
|
|
virtual void On() override
|
|
|
|
{
|
2020-12-16 16:07:24 +08:00
|
|
|
std::cout << "Turn on the equipment with a zipper switch." << std::endl;
|
2018-07-22 14:50:54 +08:00
|
|
|
m_pEe->PowerOn();
|
|
|
|
}
|
|
|
|
|
2020-12-16 16:07:24 +08:00
|
|
|
// Turn off the equipment with a zipper switch
|
2018-07-22 14:50:54 +08:00
|
|
|
virtual void Off() override
|
|
|
|
{
|
2020-12-16 16:07:24 +08:00
|
|
|
std::cout << "Turn off the equipment with a zipper switch." << std::endl;
|
2018-07-22 14:50:54 +08:00
|
|
|
m_pEe->PowerOff();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-12-16 16:07:24 +08:00
|
|
|
// Two-position switch
|
2018-07-22 14:50:54 +08:00
|
|
|
class TwoPositionSwitch : public ISwitch
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TwoPositionSwitch(IElectricalEquipment *ee) : ISwitch(ee) {}
|
|
|
|
|
2020-12-16 16:07:24 +08:00
|
|
|
// Turn on the equipment with a two-position switch
|
2018-07-22 14:50:54 +08:00
|
|
|
virtual void On() override
|
|
|
|
{
|
2020-12-16 16:07:24 +08:00
|
|
|
std::cout << "Turn on the equipment with a two-position switch." << std::endl;
|
2018-07-22 14:50:54 +08:00
|
|
|
m_pEe->PowerOn();
|
|
|
|
}
|
|
|
|
|
2020-12-16 16:07:24 +08:00
|
|
|
// Turn off the equipment with a two-position switch
|
2018-07-22 14:50:54 +08:00
|
|
|
virtual void Off() override {
|
2020-12-16 16:07:24 +08:00
|
|
|
std::cout << "Turn off the equipment with a two-position switch." << std::endl;
|
2018-07-22 14:50:54 +08:00
|
|
|
m_pEe->PowerOff();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //DESIGNPATTERN_REFINED_ABSTRACTION_H
|