au milieu des tests d'heritance de classe

This commit is contained in:
Hugo LAMY
2022-02-20 19:42:37 +01:00
parent 7e65467a27
commit 8918b348e0
10 changed files with 188 additions and 26 deletions

View File

@@ -11,6 +11,16 @@ void ScavTrap::assignValues( ScavTrap & src ) {
src._attack = 20;
}
/*
* default constructor
*/
ScavTrap::ScavTrap() {
assignValues(*this);
std::cout << _class << " " << " default construction with number " << _number << "\n";
return;
}
/*
* parameters constructor
*/
@@ -37,3 +47,34 @@ ScavTrap::~ScavTrap( void ) {
void ScavTrap::guardGate() {
std::cout << _class << " " << _name << " entered special mode Gate Keeper\n";
}
/*
* copy constructor
*/
ScavTrap::ScavTrap( ScavTrap const & src ) {
*this = src;
std::cout << _class << " " << _name << " copied\n";
return;
}
/*
* assignement operator
*/
ScavTrap & ScavTrap::operator=( ScavTrap const & rhs ) {
if ( this != &rhs )
{
this->_hit = rhs.getHit();
this->_energy = rhs.getEnergy();
this->_attack = rhs.getAttack();
this->_class = rhs.getClass();
this->_name = rhs.getName();
this->_number = rhs.getNumber();
}
std::cout << _class << " " << _name << " assigned\n";
return *this;
}