diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b1daee0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +ex0*/obj/*.o +ex0*/ex0* diff --git a/ex00/src/ClapTrap.cpp b/ex00/src/ClapTrap.cpp index 3f67e71..2b4b800 100644 --- a/ex00/src/ClapTrap.cpp +++ b/ex00/src/ClapTrap.cpp @@ -43,7 +43,7 @@ ClapTrap& ClapTrap::operator=(const ClapTrap& src) void ClapTrap::beRepaired(unsigned int amount) { - if (this->_life == 0 || this->_energy == 0) + if (this->_life <= 0 || this->_energy <= 0) { std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl; return; @@ -55,7 +55,7 @@ void ClapTrap::beRepaired(unsigned int amount) void ClapTrap::takeDamage(unsigned int amount) { - if (this->_life == 0 || this->_energy == 0) + if (this->_life <= 0) { std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl; return; @@ -66,7 +66,7 @@ void ClapTrap::takeDamage(unsigned int amount) void ClapTrap::attack(const std::string &target) { - if (this->_life == 0 || this->_energy == 0) + if (this->_life <= 0 || this->_energy <= 0) { std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl; return; diff --git a/ex00/src/main.cpp b/ex00/src/main.cpp index 3cdf88e..3674659 100644 --- a/ex00/src/main.cpp +++ b/ex00/src/main.cpp @@ -10,6 +10,7 @@ int main() claptrap1.beRepaired(10); claptrap1.attack("bozoman"); claptrap2.takeDamage(20); + claptrap1.takeDamage(1000); claptrap1.beRepaired(1000); ClapTrap tmp(claptrap1); diff --git a/ex01/src/ClapTrap.cpp b/ex01/src/ClapTrap.cpp index a016083..7ecd5e7 100644 --- a/ex01/src/ClapTrap.cpp +++ b/ex01/src/ClapTrap.cpp @@ -43,7 +43,7 @@ ClapTrap& ClapTrap::operator=(const ClapTrap& src) void ClapTrap::beRepaired(unsigned int amount) { - if (this->_life == 0 || this->_energy == 0) + if (this->_life <= 0 || this->_energy == 0) { std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl; return; @@ -55,7 +55,7 @@ void ClapTrap::beRepaired(unsigned int amount) void ClapTrap::takeDamage(unsigned int amount) { - if (this->_life == 0 || this->_energy == 0) + if (this->_life <= 0) { std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl; return; @@ -66,7 +66,7 @@ void ClapTrap::takeDamage(unsigned int amount) void ClapTrap::attack(const std::string &target) { - if (this->_life == 0 || this->_energy == 0) + if (this->_life <= 0 || this->_energy == 0) { std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl; return; diff --git a/ex01/src/ScavTrap.cpp b/ex01/src/ScavTrap.cpp index d0666b6..c3078bf 100644 --- a/ex01/src/ScavTrap.cpp +++ b/ex01/src/ScavTrap.cpp @@ -50,7 +50,7 @@ void ScavTrap::guardGate() void ScavTrap::attack(const std::string& target) { - if (this->_life == 0 || this->_energy == 0) + if (this->_life <= 0 || this->_energy == 0) { std::cerr << "error: ScavTrap " << this->_name << " dead" << std::endl; return; diff --git a/ex02/src/ClapTrap.cpp b/ex02/src/ClapTrap.cpp index a016083..7ecd5e7 100644 --- a/ex02/src/ClapTrap.cpp +++ b/ex02/src/ClapTrap.cpp @@ -43,7 +43,7 @@ ClapTrap& ClapTrap::operator=(const ClapTrap& src) void ClapTrap::beRepaired(unsigned int amount) { - if (this->_life == 0 || this->_energy == 0) + if (this->_life <= 0 || this->_energy == 0) { std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl; return; @@ -55,7 +55,7 @@ void ClapTrap::beRepaired(unsigned int amount) void ClapTrap::takeDamage(unsigned int amount) { - if (this->_life == 0 || this->_energy == 0) + if (this->_life <= 0) { std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl; return; @@ -66,7 +66,7 @@ void ClapTrap::takeDamage(unsigned int amount) void ClapTrap::attack(const std::string &target) { - if (this->_life == 0 || this->_energy == 0) + if (this->_life <= 0 || this->_energy == 0) { std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl; return; diff --git a/ex02/src/ScavTrap.cpp b/ex02/src/ScavTrap.cpp index d0666b6..c3078bf 100644 --- a/ex02/src/ScavTrap.cpp +++ b/ex02/src/ScavTrap.cpp @@ -50,7 +50,7 @@ void ScavTrap::guardGate() void ScavTrap::attack(const std::string& target) { - if (this->_life == 0 || this->_energy == 0) + if (this->_life <= 0 || this->_energy == 0) { std::cerr << "error: ScavTrap " << this->_name << " dead" << std::endl; return;