Files
42_INT_09_piscine_cpp/d03/ex01/ScavTrap.cpp

69 lines
1.7 KiB
C++

#include "ScavTrap.hpp"
/*********************************************
* CONSTRUCTORS
*********************************************/
ScavTrap::ScavTrap( std::string name ) : ClapTrap(name) {
_class = _dClass;
_hit = _dHit;
_energy = _dEnergy;
_attack = _dAttack;
std::cout << _class << " " << _name << " nb:" << _number << " created\n";
return;
}
ScavTrap::ScavTrap( ScavTrap const & src ) : ClapTrap() {
_class = _dClass;
*this = src;
std::cout << _class << " " << _name << " nb:" << _number << " copied from " << src._class << "-" << src._name << "-" << src._number << "\n";
return;
}
/*********************************************
* DESTRUCTORS
*********************************************/
ScavTrap::~ScavTrap( void ) {
std::cout << _class << " " << _name << " nb:" << _number << " destructed\n";
return;
}
/*********************************************
* OPERATORS
*********************************************/
ScavTrap & ScavTrap::operator=( ScavTrap const & rhs ) {
if ( this != &rhs )
{
_hit = rhs.getHit();
_energy = rhs.getEnergy();
_attack = rhs.getAttack();
_name = rhs.getName();
}
std::cout << _class << " " << _name << " nb:" << _number << " assigned\n";
return *this;
}
/*********************************************
* PUBLIC MEMBER FUNCTIONS
*********************************************/
void ScavTrap::guardGate() {
std::cout << _class << " " << _name << " entered special mode Gate Keeper\n";
}
/*********************************************
* STATICS
*********************************************/
std::string const ScavTrap::_dName = "robot";
std::string const ScavTrap::_dClass = "ScavTrap";
int const ScavTrap::_dHit = 100;
int const ScavTrap::_dEnergy = 50;
int const ScavTrap::_dAttack = 20;