2018-07-22 14:50:54 +08:00
|
|
|
//
|
|
|
|
// Created by xiemenghui on 2018/7/21.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef DESIGNPATTERN_CONCRETE_IMPLEMENTOR_H
|
|
|
|
#define DESIGNPATTERN_CONCRETE_IMPLEMENTOR_H
|
|
|
|
|
|
|
|
#include "implementor.h"
|
|
|
|
#include <iostream>
|
|
|
|
|
2020-12-16 16:07:24 +08:00
|
|
|
// Electric lights
|
2018-07-22 14:50:54 +08:00
|
|
|
class Light : public IElectricalEquipment
|
|
|
|
{
|
|
|
|
public:
|
2020-12-16 16:07:24 +08:00
|
|
|
// Turn on the lights
|
2018-07-22 14:50:54 +08:00
|
|
|
virtual void PowerOn() override
|
|
|
|
{
|
|
|
|
std::cout << "Light is on." << std::endl;
|
|
|
|
}
|
2020-12-16 16:07:24 +08:00
|
|
|
// Turn off the lights
|
2018-07-22 14:50:54 +08:00
|
|
|
virtual void PowerOff() override
|
|
|
|
{
|
|
|
|
std::cout << "Light is off." << std::endl;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-12-16 16:07:24 +08:00
|
|
|
// Electric Fan
|
2018-07-22 14:50:54 +08:00
|
|
|
class Fan : public IElectricalEquipment
|
|
|
|
{
|
|
|
|
public:
|
2020-12-16 16:07:24 +08:00
|
|
|
// Turn on the fan
|
2018-07-22 14:50:54 +08:00
|
|
|
virtual void PowerOn() override
|
|
|
|
{
|
|
|
|
std::cout << "Fan is on." << std::endl;
|
|
|
|
}
|
2020-12-16 16:07:24 +08:00
|
|
|
// Turn off the fan
|
2018-07-22 14:50:54 +08:00
|
|
|
virtual void PowerOff() override
|
|
|
|
{
|
|
|
|
std::cout << "Fan is off." << std::endl;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //DESIGNPATTERN_CONCRETE_IMPLEMENTOR_H
|