au milieu des tests d'heritance de classe
This commit is contained in:
@@ -6,12 +6,24 @@
|
||||
|
||||
int ClapTrap::_totalNumber = 0;
|
||||
|
||||
/*
|
||||
* assign values for default or secondary constructors
|
||||
*/
|
||||
|
||||
void ClapTrap::assignValues( ClapTrap & src ) {
|
||||
src._class = "ClapTrap";
|
||||
src._hit = 10;
|
||||
src._energy = 10;
|
||||
src._attack = 1;
|
||||
src._number = getNumber();
|
||||
}
|
||||
|
||||
/*
|
||||
* default/parametric constructor
|
||||
*/
|
||||
|
||||
ClapTrap::ClapTrap( void ) {
|
||||
|
||||
assignValues(*this);
|
||||
std::cout << "claptrap default creation without name\n";
|
||||
return;
|
||||
}
|
||||
@@ -43,12 +55,13 @@ ClapTrap & ClapTrap::operator=( ClapTrap 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();
|
||||
ClapTrap::_increaseNumber();
|
||||
_number = getNumber();
|
||||
_class = "ClapTrap";
|
||||
_hit = rhs.getHit();
|
||||
_energy = rhs.getEnergy();
|
||||
_attack = rhs.getAttack();
|
||||
_name = rhs.getName();
|
||||
}
|
||||
|
||||
std::cout << _class << " " << _name << " assigned\n";
|
||||
@@ -57,19 +70,12 @@ ClapTrap & ClapTrap::operator=( ClapTrap const & rhs ) {
|
||||
}
|
||||
|
||||
/*
|
||||
* constructor
|
||||
* parameters constructor
|
||||
*/
|
||||
|
||||
ClapTrap::ClapTrap( std::string name ) : _name(name) {
|
||||
|
||||
ClapTrap::_increaseNumber();
|
||||
|
||||
_class = "ClapTrap";
|
||||
_hit = 10;
|
||||
_energy = 10;
|
||||
_attack = 1;
|
||||
_number = getNumber();
|
||||
|
||||
assignValues(*this);
|
||||
std::cout << _class << " " << _name << " named creation with number " << _number << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user