transform d03 ex01 assignation function in case of two constructors, tests of assignation and copy operation not successful

This commit is contained in:
Hugo LAMY
2022-02-19 12:01:43 +01:00
parent 817fac957b
commit 7e65467a27
10 changed files with 104 additions and 23 deletions

View File

@@ -1,14 +1,23 @@
#include "ScavTrap.hpp"
/*
* assign values for default or secondary constructors
*/
void ScavTrap::assignValues( ScavTrap & src ) {
src._class = "ScavTrap";
src._hit = 100;
src._energy = 50;
src._attack = 20;
}
/*
* parameters constructor
*/
ScavTrap::ScavTrap( std::string name ) : ClapTrap(name) {
_class = "ScavTrap";
_hit = 100;
_energy = 50;
_attack = 20;
std::cout << _class << " " << ScavTrap::_name << " created with number " << _number << "\n";
assignValues(*this);
std::cout << _class << " " << _name << " named creation with number " << _number << "\n";
return;
}
@@ -17,7 +26,7 @@ ScavTrap::ScavTrap( std::string name ) : ClapTrap(name) {
*/
ScavTrap::~ScavTrap( void ) {
std::cout << _class << " " << ScavTrap::_name << " destructed\n";
std::cout << _class << " " << _name << " destructed\n";
return;
}
@@ -26,5 +35,5 @@ ScavTrap::~ScavTrap( void ) {
*/
void ScavTrap::guardGate() {
std::cout << _class << " " << ScavTrap::_name << " entered special mode Gate Keeper\n";
std::cout << _class << " " << _name << " entered special mode Gate Keeper\n";
}