-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfacade.h
More file actions
60 lines (55 loc) · 955 Bytes
/
facade.h
File metadata and controls
60 lines (55 loc) · 955 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include <iostream>
#include <string>
using namespace std;
class subsystem1
{
public:
string Operation1()
{
return "subsystem1 : ready!\n";
}
string Operation2()
{
return "subsystem1 : go!\n";
}
};
class subsystem2
{
public:
string Operation1()
{
return "subsystem2 : ready!\n";
}
string Operation3()
{
return "subsystem2 : fire!\n";
}
};
class facade
{
protected:
subsystem1* sys1;
subsystem2* sys2;
public:
facade(subsystem1* _sys1 = nullptr, subsystem2* _sys2 = nullptr)
{
this->sys1 = _sys1? _sys1 : new subsystem1;
this->sys2 = _sys2? _sys2 : new subsystem2;
}
~facade()
{
delete sys1;
delete sys2;
}
string Operation()
{
string result = "facade initialize system : \n";
result += this->sys1->Operation1();
result += this->sys2->Operation1();
result += "facade other system action: \n";
result += this->sys1->Operation2();
result += this->sys2->Operation3();
return result;
}
};