fix(norm): add copy contructor
This commit is contained in:
parent
7fb5f99a7a
commit
57de4fa948
20 changed files with 93 additions and 0 deletions
|
|
@ -7,6 +7,14 @@ ClapTrap::ClapTrap()
|
|||
std::cout << "ClapTrap::ClapTrap()" << std::endl;
|
||||
}
|
||||
|
||||
ClapTrap::ClapTrap(const ClapTrap &other) {
|
||||
name = other.name;
|
||||
hit_points = other.hit_points;
|
||||
energy_points = other.energy_points;
|
||||
attack_damage = other.attack_damage;
|
||||
std::cout << "ClapTrap::ClapTrap(const ClapTrap &other)" << std::endl;
|
||||
}
|
||||
|
||||
ClapTrap::ClapTrap(std::string name)
|
||||
: name(name), hit_points(10), energy_points(10), attack_damage(0) {
|
||||
std::cout << "ClapTrap::ClapTrap(" << name << ")" << std::endl;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ protected:
|
|||
|
||||
public:
|
||||
ClapTrap();
|
||||
ClapTrap(const ClapTrap &other);
|
||||
ClapTrap(std::string name);
|
||||
~ClapTrap();
|
||||
ClapTrap &operator=(const ClapTrap &other);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,14 @@ ScavTrap::ScavTrap() {
|
|||
attack_damage = 20;
|
||||
}
|
||||
|
||||
ScavTrap::ScavTrap(const ScavTrap &other) {
|
||||
name = other.name;
|
||||
hit_points = other.hit_points;
|
||||
energy_points = other.energy_points;
|
||||
attack_damage = other.attack_damage;
|
||||
std::cout << "ScavTrap::ScavTrap(const ScavTrap &other)" << std::endl;
|
||||
}
|
||||
|
||||
ScavTrap::ScavTrap(std::string name) {
|
||||
std::cout << "ScavTrap::ScavTrap(" << name << ")" << std::endl;
|
||||
hit_points = 100;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
class ScavTrap : public ClapTrap {
|
||||
public:
|
||||
ScavTrap();
|
||||
ScavTrap(const ScavTrap &other);
|
||||
ScavTrap(std::string name);
|
||||
~ScavTrap();
|
||||
ScavTrap &operator=(const ScavTrap &other);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue