-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScavTrap.cpp
More file actions
62 lines (55 loc) · 1.59 KB
/
ScavTrap.cpp
File metadata and controls
62 lines (55 loc) · 1.59 KB
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
#include "ScavTrap.hpp"
#include "ClapTrap.hpp"
ScavTrap::ScavTrap () : ClapTrap ()
{
print ("ScavTrap default constructor called");
this->_hitPoints = 100;
this->_energyPoints = 50;
this->_attackDamage = 20;
}
ScavTrap::ScavTrap (const ScavTrap &other) : ClapTrap (other)
{
print ("ScavTrap copy constructor called");
*this = other;
}
ScavTrap &
ScavTrap::operator= (const ScavTrap &other)
{
print ("ScavTrap assigment operator called");
if (this != &other)
{
this->setName (other.getName ());
this->setHitPoints (other.getHitPoints ());
this->setEnergyPoints (other.getEnergyPoints ());
this->setAttackDamage (other.getAttackDamage ());
}
return *this;
}
ScavTrap::~ScavTrap () { print ("ScavTrap destructor called"); }
ScavTrap::ScavTrap (std::string name) : ClapTrap (name)
{
print ("ScavTrap name constructor called");
this->_hitPoints = 100;
this->_energyPoints = 50;
this->_attackDamage = 20;
}
void
ScavTrap::guardGate ()
{
print ("ScavTrap " << this->getName ()
<< " have enterred in Gate keeper mode");
}
void
ScavTrap::attack (const std::string &target)
{
if (this->getHitPoints () <= 0)
print ("ScavTrap " << this->getName () << " is dead and can't attack!");
else if (this->getEnergyPoints () <= 0)
print ("ScavTrap " << this->getName ()
<< " is out of energy and can't attack!");
else
print ("ScavTrap " << this->getName () << " attack " << target
<< " causing " << this->getAttackDamage ()
<< " points of damage!");
_energyPoints -= 1;
}