blob: 6d68225f31fba6b898c8502b44eb59d876f86779 (
plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 15:50:35 by charles #+# #+# */
/* Updated: 2020/12/11 11:30:48 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "ISpaceMarine.hpp"
#include "ISquad.hpp"
#include "Squad.hpp"
#include "TacticalMarine.hpp"
#include "AssaultTerminator.hpp"
int main()
{
{
std::cout << "================ SUBJECT MAIN =====================" << std::endl;
ISpaceMarine* bob = new TacticalMarine;
ISpaceMarine* jim = new AssaultTerminator;
ISquad* vlc = new Squad;
vlc->push(bob);
vlc->push(jim);
for (int i = 0; i < vlc->getCount(); ++i)
{
ISpaceMarine* cur = vlc->getUnit(i);
cur->battleCry();
cur->rangedAttack();
cur->meleeAttack();
}
delete vlc;
}
std::cout << std::endl;
{
std::cout << "================ TACTICAL MARINE =====================" << std::endl;
TacticalMarine t;
t.battleCry();
t.rangedAttack();
t.meleeAttack();
TacticalMarine t2(t);
TacticalMarine t3;
t3 = t;
std::cout << "################ INTERFACE" << std::endl;
ISpaceMarine *sm = new TacticalMarine();
sm->battleCry();
sm->rangedAttack();
sm->meleeAttack();
delete sm;
}
std::cout << std::endl;
{
std::cout << "================ ASSAULT TERMINATOR =====================" << std::endl;
AssaultTerminator a;
a.battleCry();
a.rangedAttack();
a.meleeAttack();
AssaultTerminator a2(a);
AssaultTerminator a3;
a3 = a;
std::cout << "################ INTERFACE" << std::endl;
ISpaceMarine *sm = new AssaultTerminator();
sm->battleCry();
sm->rangedAttack();
sm->meleeAttack();
delete sm;
}
std::cout << std::endl;
{
std::cout << "================ SQUAD =====================" << std::endl;
Squad s;
std::cout << "Count: " << s.getCount() << std::endl;
std::cout << "Count (push): " << s.push(new TacticalMarine()) << std::endl;
s.push(new TacticalMarine());
s.push(new AssaultTerminator());
s.push(new AssaultTerminator());
std::cout << "Count: " << s.getCount() << std::endl;
s.getUnit(0)->battleCry();
s.getUnit(1)->battleCry();
s.getUnit(2)->battleCry();
s.getUnit(3)->battleCry();
s.getUnit(3)->rangedAttack();
s.getUnit(3)->meleeAttack();
s.getUnit(0)->rangedAttack();
s.getUnit(0)->meleeAttack();
std::cout << s.getUnit(4) << std::endl;
std::cout << s.getUnit(-1) << std::endl;
std::cout << "################ COPY" << std::endl;
Squad s2(s);
std::cout << "Copy Count: " << s2.getCount() << std::endl;
s2.push(new TacticalMarine());
std::cout << "Copy Count: " << s2.getCount() << std::endl;
std::cout << "Origin Count: " << s.getCount() << std::endl;
std::cout << "################ ASSIGN" << std::endl;
Squad s3(s2);
s3 = s;
std::cout << "Copy Count: " << s3.getCount() << std::endl;
s3.push(new TacticalMarine());
std::cout << "Copy Count: " << s3.getCount() << std::endl;
std::cout << "Origin Count: " << s.getCount() << std::endl;
std::cout << "################ INTERFACE" << std::endl;
ISquad *si = new Squad();
si->push(new TacticalMarine());
std::cout << si->getCount() << std::endl;
si->getUnit(0)->battleCry();
si->push(new AssaultTerminator());
std::cout << si->getCount() << std::endl;
si->getUnit(1)->battleCry();
delete si;
std::cout << "################ DESTROY" << std::endl;
}
return 0;
}
|