-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
81 lines (54 loc) · 1.71 KB
/
main.cpp
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using namespace std;
// standart headers
#include <iostream>
#include <vector>
// custom headers
#include "Archer/Archer.h"
#include "Infantryman/Infantryman.h"
#include "Horseman/Horseman.h"
#include "CompositeUnit/CompositeUnit.h"
#include "ConcreteArmy/ConcreteArmy.h"
#include "ConcreteMediator/ConcreteMediator.h"
CompositeUnit* createRomanLegion()
{
CompositeUnit* romanLegion = new CompositeUnit;
for (int i = 0; i<3000; ++i)
romanLegion->addUnit(new Infantryman);
for (int i = 0; i<1500; ++i)
romanLegion->addUnit(new Archer);
for (int i = 0; i<500; ++i)
romanLegion->addUnit(new Horseman);
return romanLegion;
}
CompositeUnit* createGreekLegion()
{
CompositeUnit* greekLegion = new CompositeUnit;
for (int i = 0; i<2000; ++i)
greekLegion->addUnit(new Infantryman);
for (int i = 0; i<1000; ++i)
greekLegion->addUnit(new Archer);
for (int i = 0; i<500; ++i)
greekLegion->addUnit(new Horseman);
return greekLegion;
}
int main()
{
ConcreteMediator mediator;
ConcreteArmy* romanArmy = new ConcreteArmy("Roman army", &mediator);
ConcreteArmy* greekArmy = new ConcreteArmy("Greek army", &mediator);
for (int i = 0; i < 4; ++i)
romanArmy->addUnit(createRomanLegion());
for (int i = 0; i < 5; i++)
greekArmy->addUnit(createGreekLegion());
cout << "Roman army damaging strength is " << romanArmy->getStrength() << endl;
cout << "Greek army damaging strength is " << greekArmy->getStrength() << endl;
mediator.SetArmy1(romanArmy);
mediator.SetArmy2(greekArmy);
romanArmy->Send("Are you ready to die, dirty hellens?");
greekArmy->Send("Doing is better than saying, nasty legionnaires!");
cout << "Press \"ENTER\" to exit";
cin.get();
delete romanArmy;
delete greekArmy;
return 0;
}