forked from FengJungle/DesignPattern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
44 lines (35 loc) · 927 Bytes
/
main.cpp
File metadata and controls
44 lines (35 loc) · 927 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
#include "Observer.h"
#include "AllyCenter.h"
int main()
{
// 创建一个战队
AllyCenterController *controller = new AllyCenterController();
// 创建4个玩家,并加入战队
Player *Jungle = new Player("Jungle");
Player *Single = new Player("Single");
Player *Jianmengtu = new Player("������");
Player *SillyDog = new Player("ɵ�ӹ�");
controller->join(Jungle);
controller->join(Single);
controller->join(Jianmengtu);
controller->join(SillyDog);
printf("\n\n");
// Jungle发现物资,呼叫队友
Jungle->call(RESOURCE, controller);
printf("\n\n");
// 傻子狗遇到危险,求救队友
SillyDog->call(HELP, controller);
printf("\n\n");
system("pause");
delete controller;
delete Jungle;
delete Single;
delete Jianmengtu;
delete SillyDog;
controller = nullptr;
Jungle = nullptr;
Single = nullptr;
Jianmengtu = nullptr;
SillyDog = nullptr;
return 0;
}