-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
55 lines (41 loc) · 1.21 KB
/
main.cpp
File metadata and controls
55 lines (41 loc) · 1.21 KB
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
#include <iostream>
#include <cmath>
#include <memory>
#include <vector>
#include "./src/builder/index.hpp"
#include "./src/prototype/index.hpp"
#include "./src/factory/index.hpp"
#include "./src/singleton/index.hpp"
#include "./src/adapter/index.hpp"
#include "./src/bridge/index.hpp"
#include "./src/composite/index.hpp"
#include "./src/decorator/index.hpp"
#include "./src/flyweight/index.hpp"
#include "./src/proxy/index.hpp"
#include "./src/chain_of_responsibility/index.hpp"
#include "./src/command/index.hpp"
using namespace std;
int main(int argc, char *argv[])
{
command::BankAccount ba;
vector<command::BankAccountCommand> commands {
command::BankAccountCommand{ba, command::BankAccountCommand::Action::deposit, 100},
command::BankAccountCommand{ba, command::BankAccountCommand::Action::withdraw, 200}
};
cout << ba << endl;
for (auto& cmd : commands) {
cmd.call();
}
for (auto it = commands.rbegin(); it != commands.rend(); ++it) {
it->undo();
}
cout << ba << endl;
//composite
command::BankAccount ba2;
ba2.deposit(100);
command::MoneyTransferCommand cmd{ba, ba2, 50000};
cmd.call();
cout << ba << endl << ba2 << endl;
cmd.undo();
cout << ba << endl << ba2 << endl;
}