-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFragTrap.cpp
73 lines (62 loc) · 2.56 KB
/
FragTrap.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* FragTrap.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wcorrea- <wcorrea-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/17 18:45:06 by wcorrea- #+# #+# */
/* Updated: 2023/07/24 23:52:24 by wcorrea- ### ########.fr */
/* */
/* ************************************************************************** */
#include "FragTrap.hpp"
// --------------------------- CONSTURCTORS ----------------------------------
FragTrap::FragTrap(void)
{
std::cout << "FragTrap default constructor called" << std::endl;
this->_hitPoints = this->initHit;
this->_energyPoints = this->initEnergy;
this->_attackDamage = this->initDamage;
}
FragTrap::FragTrap(std::string const name) : ClapTrap(name)
{
std::cout << "FragTrap constructor with parameter called" << std::endl;
this->_hitPoints = this->initHit;
this->_energyPoints = this->initEnergy;
this->_attackDamage = this->initDamage;
}
FragTrap::FragTrap(FragTrap const ©) : ClapTrap(copy)
{
std::cout << "FragTrap copy constructor called" << std::endl;
}
FragTrap::~FragTrap(void)
{
std::cout << "FragTrap destructor called" << std::endl;
}
// --------------------------- OPERATORS ----------------------------------
FragTrap &FragTrap::operator = (FragTrap const ©)
{
if (this == ©)
return (*this);
this->_name = copy.getName();
this->_hitPoints = copy.getHitPoints();
this->_energyPoints = copy.getEnergyPoints();
this->_attackDamage = copy.getAttackDamage();
return (*this);
}
// --------------------------- MEMBER FUNCTIONS ----------------------------------
void FragTrap::attack(std::string const &target)
{
if (!this->_energyPoints || !this->_hitPoints)
{
std::cout << "FragTrap " << this->_name << " is out of action!" << std::endl;
return ;
}
std::cout << "FragTrap " << this->_name << " bombs " << target;
std::cout << ", causing " << this->_attackDamage << " points of damage!" << std::endl;
this->_energyPoints--;
}
void FragTrap::highFivesGuys(void)
{
std::cout << "FragTrap " << this->_name << " high fives everyone!" << std::endl;
}