2018-07-22 14:50:54 +08:00
|
|
|
//
|
|
|
|
// Created by xiemenghui on 2018/7/21.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "BridgeMain.h"
|
|
|
|
|
|
|
|
void BridgeMain()
|
|
|
|
{
|
2020-12-16 16:07:24 +08:00
|
|
|
// Create electrical appliances (electric lights, electric fans)
|
2018-07-22 14:50:54 +08:00
|
|
|
IElectricalEquipment * light = new Light();
|
|
|
|
IElectricalEquipment * fan = new Fan();
|
|
|
|
|
2020-12-16 16:07:24 +08:00
|
|
|
// Create switch (pull chain switch, two-position switch)
|
|
|
|
// Associating a pull chain switch with a light and a two-position switch with a fan
|
2018-07-22 14:50:54 +08:00
|
|
|
ISwitch * pullChain = new PullChainSwitch(light);
|
|
|
|
ISwitch * twoPosition = new TwoPositionSwitch(fan);
|
|
|
|
|
2020-12-16 16:07:24 +08:00
|
|
|
// Lights on, lights off
|
2018-07-22 14:50:54 +08:00
|
|
|
pullChain->On();
|
|
|
|
pullChain->Off();
|
|
|
|
|
2020-12-16 16:07:24 +08:00
|
|
|
// Turn on the fan, turn off the fan
|
2018-07-22 14:50:54 +08:00
|
|
|
twoPosition->On();
|
|
|
|
twoPosition->Off();
|
|
|
|
|
|
|
|
SAFE_DELETE(twoPosition);
|
|
|
|
SAFE_DELETE(pullChain);
|
|
|
|
SAFE_DELETE(fan);
|
|
|
|
SAFE_DELETE(light);
|
|
|
|
}
|