-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHero.class.cpp
executable file
·82 lines (70 loc) · 1.43 KB
/
Hero.class.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
82
#include "Hero.class.hpp"
Hero::Hero(void)
{
std::cout << "[Constructor] Default constructor called" << std::endl;
return;
}
Hero::~Hero(void)
{
std::cout << "[Destructor] Destructor called" << std::endl;
return;
}
Hero::Hero(const Hero & src) : IElement (src)
{
std::cout << "[Constructor] Copy constructor called" << std::endl;
*this = src;
return;
}
Hero::Hero(
unsigned int hp,
unsigned int posX,
unsigned int posY,
unsigned int sizeX,
unsigned int sizeY,
int speed,
std::string *skin,
char upgrade,
unsigned int life,
unsigned int rateOfFire
) : IElement(hp, posX, posY, sizeX, sizeY, speed, skin), _upgrade(upgrade), _life(life), _rateOfFire(rateOfFire)
{
return;
}
char Hero::getUpgrade(void) const
{
return (this->_upgrade);
}
void Hero::setUpgrade(char upgrade)
{
this->_upgrade = upgrade;
return;
}
unsigned int Hero::getLife(void) const
{
return (this->_life);
}
void Hero::setLife(unsigned int life)
{
this->_life = life;
return;
}
unsigned int Hero::getRateOfFire(void) const
{
return(this->_rateOfFire);
}
void Hero::setRateOfFire(unsigned int rateOfFire)
{
this->_rateOfFire = rateOfFire;
return;
}
const Hero & Hero::operator=(const Hero & rhs)
{
this->setUpgrade(rhs.getUpgrade());
this->setLife(rhs.getLife());
return (*this);
}
std::ostream & operator<<(std::ostream & o, const Hero & rhs)
{
o << "UPGRADE: " << rhs.getUpgrade() << "LIFE: " << rhs.getLife();
return (o);
}