first commit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
#include "FragTrap.hpp"
|
||||
|
||||
FragTrap::FragTrap(): ClapTrap()
|
||||
{
|
||||
this->_hit_pts = 100;
|
||||
this->_energy_pts = 100;
|
||||
this->_attack_dmg = 30;
|
||||
std::cout << "FragTrap Default Constructor called" << std::endl;
|
||||
}
|
||||
|
||||
FragTrap::FragTrap(const FragTrap ©): ClapTrap(copy)
|
||||
{
|
||||
std::cout << "FragTrap Copy Constructor called" << std::endl;
|
||||
}
|
||||
|
||||
FragTrap::FragTrap(std::string name): ClapTrap(name)
|
||||
{
|
||||
this->_hit_pts = 100;
|
||||
this->_energy_pts = 100;
|
||||
this->_attack_dmg = 30;
|
||||
std::cout << "FragTrap Constructor " << this->_name << " called" << std::endl;
|
||||
}
|
||||
|
||||
FragTrap::~FragTrap()
|
||||
{
|
||||
std::cout << "FragTrap Deconstructor " << this->_name << " called" << std::endl;
|
||||
}
|
||||
|
||||
FragTrap &FragTrap::operator=(const FragTrap &src)
|
||||
{
|
||||
std::cout << "FragTrap Assignation operator called" << std::endl;
|
||||
this->_name = src._name;
|
||||
this->_hit_pts = src._hit_pts;
|
||||
this->_energy_pts = src._energy_pts;
|
||||
this->_attack_dmg = src._attack_dmg;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void FragTrap::attack(const std::string &target)
|
||||
{
|
||||
if (this->_energy_pts > 0 && this->_hit_pts > 0)
|
||||
{
|
||||
std::cout << "FragTrap " << this->_name << " attacks " << target << ", causing " << this->_attack_dmg << " damage!" << std::endl;
|
||||
this->_energy_pts--;
|
||||
}
|
||||
else if (this->_energy_pts == 0)
|
||||
std::cout << "FragTrap " << this->_name << " is not able to attack " << target << ", because he has no energy points left." << std::endl;
|
||||
else
|
||||
std::cout << "FragTrap " << this->_name << " is not able to attack " << target << ", because he is dead" << std::endl;
|
||||
}
|
||||
|
||||
void FragTrap::highFivesGuys() {
|
||||
std::cout << "FragTrap " << this->_name << " requests a positive high-five! ✋" << std::endl;
|
||||
}
|
||||
Reference in New Issue
Block a user