-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBridgeMain.cpp
More file actions
30 lines (24 loc) · 782 Bytes
/
BridgeMain.cpp
File metadata and controls
30 lines (24 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//
// Created by xiemenghui on 2018/7/21.
//
#include "BridgeMain.h"
void BridgeMain()
{
// Create electrical appliances (electric lights, electric fans)
IElectricalEquipment * light = new Light();
IElectricalEquipment * fan = new Fan();
// Create switch (pull chain switch, two-position switch)
// Associating a pull chain switch with a light and a two-position switch with a fan
ISwitch * pullChain = new PullChainSwitch(light);
ISwitch * twoPosition = new TwoPositionSwitch(fan);
// Lights on, lights off
pullChain->On();
pullChain->Off();
// Turn on the fan, turn off the fan
twoPosition->On();
twoPosition->Off();
SAFE_DELETE(twoPosition);
SAFE_DELETE(pullChain);
SAFE_DELETE(fan);
SAFE_DELETE(light);
}