This commit is contained in:
Camille Chauvet 2023-08-29 15:15:12 +02:00
parent 6669f8b137
commit 91c1a2d3e2
7 changed files with 14 additions and 11 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
ex0*/obj/*.o
ex0*/ex0*

View File

@ -43,7 +43,7 @@ ClapTrap& ClapTrap::operator=(const ClapTrap& src)
void ClapTrap::beRepaired(unsigned int amount) 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; std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl;
return; return;
@ -55,7 +55,7 @@ void ClapTrap::beRepaired(unsigned int amount)
void ClapTrap::takeDamage(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; std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl;
return; return;
@ -66,7 +66,7 @@ void ClapTrap::takeDamage(unsigned int amount)
void ClapTrap::attack(const std::string &target) 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; std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl;
return; return;

View File

@ -10,6 +10,7 @@ int main()
claptrap1.beRepaired(10); claptrap1.beRepaired(10);
claptrap1.attack("bozoman"); claptrap1.attack("bozoman");
claptrap2.takeDamage(20); claptrap2.takeDamage(20);
claptrap1.takeDamage(1000);
claptrap1.beRepaired(1000); claptrap1.beRepaired(1000);
ClapTrap tmp(claptrap1); ClapTrap tmp(claptrap1);

View File

@ -43,7 +43,7 @@ ClapTrap& ClapTrap::operator=(const ClapTrap& src)
void ClapTrap::beRepaired(unsigned int amount) 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; std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl;
return; return;
@ -55,7 +55,7 @@ void ClapTrap::beRepaired(unsigned int amount)
void ClapTrap::takeDamage(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; std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl;
return; return;
@ -66,7 +66,7 @@ void ClapTrap::takeDamage(unsigned int amount)
void ClapTrap::attack(const std::string &target) 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; std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl;
return; return;

View File

@ -50,7 +50,7 @@ void ScavTrap::guardGate()
void ScavTrap::attack(const std::string& target) 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; std::cerr << "error: ScavTrap " << this->_name << " dead" << std::endl;
return; return;

View File

@ -43,7 +43,7 @@ ClapTrap& ClapTrap::operator=(const ClapTrap& src)
void ClapTrap::beRepaired(unsigned int amount) 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; std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl;
return; return;
@ -55,7 +55,7 @@ void ClapTrap::beRepaired(unsigned int amount)
void ClapTrap::takeDamage(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; std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl;
return; return;
@ -66,7 +66,7 @@ void ClapTrap::takeDamage(unsigned int amount)
void ClapTrap::attack(const std::string &target) 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; std::cout << "error: ClapTrap " << this->_name << " dead" << std::endl;
return; return;

View File

@ -50,7 +50,7 @@ void ScavTrap::guardGate()
void ScavTrap::attack(const std::string& target) 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; std::cerr << "error: ScavTrap " << this->_name << " dead" << std::endl;
return; return;