From 7afa19456df5adb2351f12e76efb166e648c3a3b Mon Sep 17 00:00:00 2001 From: kinou-p Date: Mon, 1 Aug 2022 23:07:23 +0200 Subject: [PATCH] pre push --- cpp02/ex00/Fixed.cpp | 6 ++-- cpp02/ex00/Fixed.hpp | 7 ++-- cpp02/ex01/Fixed.cpp | 10 +++--- cpp02/ex02/Fixed.cpp | 10 +++--- cpp02/ex02/main.cpp | 25 ++------------ cpp03/ex00/ClapTrap.cpp | 45 +++++++++++------------- cpp03/ex00/ClapTrap.hpp | 7 +--- cpp03/ex00/main.cpp | 29 ++++++++++++++-- cpp03/ex01/ClapTrap.cpp | 45 +++++++++++------------- cpp03/ex01/ClapTrap.hpp | 13 +++---- cpp03/ex01/main.cpp | 39 +++++++++++++++++---- cpp03/ex02/ClapTrap.cpp | 46 ++++++++++++------------- cpp03/ex02/ClapTrap.hpp | 13 +++---- cpp03/ex02/main.cpp | 76 +++++++++++++++++++++++++++++++++++++---- 14 files changed, 219 insertions(+), 152 deletions(-) diff --git a/cpp02/ex00/Fixed.cpp b/cpp02/ex00/Fixed.cpp index 2fb231a..af02fca 100644 --- a/cpp02/ex00/Fixed.cpp +++ b/cpp02/ex00/Fixed.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/22 00:58:04 by apommier #+# #+# */ -/* Updated: 2022/07/22 13:23:40 by apommier ### ########.fr */ +/* Updated: 2022/07/30 16:13:13 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,7 +26,7 @@ Fixed::~Fixed() Fixed::Fixed(const Fixed& copy) { std::cout << "Copy constructor called\n"; - this->_value = copy.getRawBits(); + *this = copy; } int Fixed::getRawBits(void) const @@ -43,7 +43,7 @@ void Fixed::setRawBits(int const raw) Fixed & Fixed::operator=(const Fixed& op) { - std::cout << "Assignation operator called" << std::endl; + std::cout << "Copy assignment operator called" << std::endl; if (this != &op) this->_value = op.getRawBits(); return (*this); diff --git a/cpp02/ex00/Fixed.hpp b/cpp02/ex00/Fixed.hpp index ed6d20d..e550605 100644 --- a/cpp02/ex00/Fixed.hpp +++ b/cpp02/ex00/Fixed.hpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/22 00:58:18 by apommier #+# #+# */ -/* Updated: 2022/07/22 13:23:04 by apommier ### ########.fr */ +/* Updated: 2022/07/30 16:09:26 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,13 +24,14 @@ class Fixed { ~Fixed(); int getRawBits(void) const; void setRawBits(int const raw); - + Fixed &operator=(const Fixed& op); + private: int _value; const static int _fraction = 8; }; -std::ostream &operator<<(std::ostream &out, const Fixed &nbr); +//std::ostream &operator<<(std::ostream &out, const Fixed &nbr); #endif \ No newline at end of file diff --git a/cpp02/ex01/Fixed.cpp b/cpp02/ex01/Fixed.cpp index 734ba8e..acf271e 100644 --- a/cpp02/ex01/Fixed.cpp +++ b/cpp02/ex01/Fixed.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/22 15:31:03 by apommier #+# #+# */ -/* Updated: 2022/07/12 04:40:22 by apommier ### ########.fr */ +/* Updated: 2022/07/30 16:36:28 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,19 +25,19 @@ Fixed::~Fixed() Fixed::Fixed(const float nbr) { - std::cout << "Float constructor called\n"; - this->_value = (int)(roundf(nbr * (1 << this->_fraction))); + std::cout << "Float constructor called\n" << nbr << std::endl; + this->_value = roundf(nbr * (1 << this->_fraction)); } Fixed::Fixed(const int nbr) { std::cout << "Int constructor called\n"; - this->_value = nbr;this->_value = nbr << this->_fraction; + this->_value = nbr; } Fixed & Fixed::operator=(const Fixed& op) { - std::cout << "Assignation operator called" << std::endl; + std::cout << "Copy assignment operator called" << std::endl; if (this != &op) this->_value = op.getRawBits(); return (*this); diff --git a/cpp02/ex02/Fixed.cpp b/cpp02/ex02/Fixed.cpp index 13a0ff8..8996c43 100644 --- a/cpp02/ex02/Fixed.cpp +++ b/cpp02/ex02/Fixed.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/22 15:31:03 by apommier #+# #+# */ -/* Updated: 2022/07/22 13:36:04 by apommier ### ########.fr */ +/* Updated: 2022/08/01 12:25:54 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -77,7 +77,7 @@ std::ostream &operator<<(std::ostream &out, const Fixed &nbr) Fixed &Fixed::operator=(const Fixed& arg) { - std::cout << "Assignation operator called" << std::endl; + std::cout << "Copy assignment operator called" << std::endl; if (this != &arg) this->_value = arg.getRawBits(); return (*this); @@ -158,7 +158,7 @@ Fixed &Fixed::operator++(void) Fixed Fixed::operator++(int) { Fixed ret(*this); - ret.operator++(); + ++(*this); return (ret); } @@ -171,7 +171,7 @@ Fixed &Fixed::operator--(void) Fixed Fixed::operator--(int) { Fixed ret(*this); - ret.operator--(); + --(*this); return (ret); } @@ -186,7 +186,7 @@ Fixed &Fixed::min(Fixed& arg, Fixed& argTwo) const Fixed &Fixed::min(const Fixed& arg, const Fixed& argTwo) { - if (arg< argTwo) + if (arg < argTwo) return (arg); return (argTwo); } diff --git a/cpp02/ex02/main.cpp b/cpp02/ex02/main.cpp index 8ab7b92..864cbdf 100644 --- a/cpp02/ex02/main.cpp +++ b/cpp02/ex02/main.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/22 15:31:09 by apommier #+# #+# */ -/* Updated: 2022/07/22 13:29:02 by apommier ### ########.fr */ +/* Updated: 2022/07/30 16:53:00 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,34 +17,15 @@ int main( void ) Fixed a; Fixed const b( Fixed( 5.05f ) * Fixed( 2 ) ); - float test = a.getRawBits(); - - std::cout << test << std::endl; - std::cout << "--1--" << std::endl; - std::cout << ++test << std::endl; - std::cout << "--2--" << std::endl; - std::cout << test << std::endl; - std::cout << "--3--" << std::endl; - std::cout << test++ << std::endl; - std::cout << "--4--" << std::endl; - std::cout << test << std::endl; - std::cout << "--5--" << std::endl; - - std::cout << "--0--" << std::endl; std::cout << a << std::endl; - std::cout << "--1--" << std::endl; std::cout << ++a << std::endl; - std::cout << "--2--" << std::endl; std::cout << a << std::endl; - std::cout << "--3--" << std::endl; std::cout << a++ << std::endl; - std::cout << "--4--" << std::endl; std::cout << a << std::endl; - std::cout << "--5--" << std::endl; std::cout << b << std::endl; - + std::cout << Fixed::max( a, b ) << std::endl; + return 0; - return (0); } \ No newline at end of file diff --git a/cpp03/ex00/ClapTrap.cpp b/cpp03/ex00/ClapTrap.cpp index a44476f..ce9ab49 100644 --- a/cpp03/ex00/ClapTrap.cpp +++ b/cpp03/ex00/ClapTrap.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/13 05:22:49 by apommier #+# #+# */ -/* Updated: 2022/07/14 01:16:51 by apommier ### ########.fr */ +/* Updated: 2022/08/01 13:12:47 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -69,34 +69,19 @@ int ClapTrap::getAttackDamage(void) const return (this->_attackDamage); } -/*std::string ClapTrap::setName(std::string name) -{ - this->_name = name; -} - -void ClapTrap::setHitPoints(int hitPoints) -{ - this->_hitPoints = hitPoints; -} - -void ClapTrap::setEnergyPoints(int energyPoints) -{ - this->_energyPoints = energyPoints; -} - -void ClapTrap::setAttackDamage(int attackDamage) -{ - this->_attackDamage = attackDamage; -}*/ - //member function void ClapTrap::attack(const std::string& target) { if (this->_hitPoints <= 0) std::cout << "ClapTrap " << this->_name << " could not attack because he died" << std::endl; - else + else if (this->_energyPoints <= 0) + std::cout << "ClapTrap " << this->_name << " could not attack because he don't have energy" << std::endl; + else + { std::cout << "ClapTrap " << this->_name << " attacks " << target << ", causing " << this->_attackDamage << " points of damage!" << std::endl; + this->_energyPoints--; + } } void ClapTrap::takeDamage(unsigned int amount) @@ -107,11 +92,21 @@ void ClapTrap::takeDamage(unsigned int amount) else if (this->_hitPoints - amount <= 0) std::cout << "ClapTrap " << this->_name << " died" << std::endl; this->_hitPoints -= amount; - std::cout << "ClapTrap " << this->_name << " have " << this->_hitPoints << " hit points" << std::endl; + if (this->_hitPoints > 0) + std::cout << "ClapTrap " << this->_name << " have " << this->_hitPoints << " hit points" << std::endl; } void ClapTrap::beRepaired(unsigned int amount) { - std::cout << "ClapTrap " << this->_name << " regain " << amount << " hit point(s)!" << std::endl; - this->_hitPoints += amount; + if (this->_hitPoints <= 0) + std::cout << "ClapTrap " << this->_name << " could not repair because he died" << std::endl; + else if (this->_energyPoints <= 0) + std::cout << "ClapTrap " << this->_name << " could not repair because he don't have energy" << std::endl; + else + { + std::cout << "ClapTrap " << this->_name << " regain " << amount << " hit point(s)!" << std::endl; + this->_hitPoints += amount; + std::cout << "ClapTrap " << this->_name << " have " << this->_hitPoints << " hit points" << std::endl; + this->_energyPoints--; + } } diff --git a/cpp03/ex00/ClapTrap.hpp b/cpp03/ex00/ClapTrap.hpp index aec2afe..76eb158 100644 --- a/cpp03/ex00/ClapTrap.hpp +++ b/cpp03/ex00/ClapTrap.hpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/13 05:22:53 by apommier #+# #+# */ -/* Updated: 2022/07/14 01:10:29 by apommier ### ########.fr */ +/* Updated: 2022/08/01 13:23:46 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,11 +32,6 @@ class ClapTrap { int getEnergyPoints(void) const; int getAttackDamage(void) const; - /*std::string setName(std::string name); - int setHitPoints(int hitPoints); - int setEnergyPoints(int energyPoints); - int setAttackDamage(int attackDamage);*/ - private: std::string _name; diff --git a/cpp03/ex00/main.cpp b/cpp03/ex00/main.cpp index 22fd144..6a46e23 100644 --- a/cpp03/ex00/main.cpp +++ b/cpp03/ex00/main.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/13 05:22:55 by apommier #+# #+# */ -/* Updated: 2022/07/13 06:53:00 by apommier ### ########.fr */ +/* Updated: 2022/08/01 12:59:35 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,32 @@ int main() John.takeDamage(5); John.takeDamage(4); John.takeDamage(1); - John.takeDamage(1); John.attack("Jean"); + John.beRepaired(100); + + std::cout << std::endl; + ClapTrap John2(John); + John2.attack("Jean"); + John2.takeDamage(5); + John2.beRepaired(100); + + std::cout << std::endl; + ClapTrap John3("John3"); + John3.beRepaired(100); + John3.attack("Jean"); + John3.beRepaired(100); + John3.attack("Jean"); + John3.beRepaired(100); + John3.attack("Jean"); + John3.beRepaired(100); + John3.attack("Jean"); + John3.beRepaired(100); + John3.attack("Jean"); + std::cout << std::endl; + John3.beRepaired(100); + John3.attack("Jean"); + John3.takeDamage(100); + + return (0); } \ No newline at end of file diff --git a/cpp03/ex01/ClapTrap.cpp b/cpp03/ex01/ClapTrap.cpp index 9500d3e..051fbd9 100644 --- a/cpp03/ex01/ClapTrap.cpp +++ b/cpp03/ex01/ClapTrap.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/13 05:22:49 by apommier #+# #+# */ -/* Updated: 2022/07/14 01:16:39 by apommier ### ########.fr */ +/* Updated: 2022/08/01 13:13:03 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -69,34 +69,19 @@ int ClapTrap::getAttackDamage(void) const return (this->_attackDamage); } -/*std::string ClapTrap::setName(std::string name) -{ - this->_name = name; -} - -void ClapTrap::setHitPoints(int hitPoints) -{ - this->_hitPoints = hitPoints; -} - -void ClapTrap::setEnergyPoints(int energyPoints) -{ - this->_energyPoints = energyPoints; -} - -void ClapTrap::setAttackDamage(int attackDamage) -{ - this->_attackDamage = attackDamage; -}*/ - //member function void ClapTrap::attack(const std::string& target) { if (this->_hitPoints <= 0) std::cout << "ClapTrap " << this->_name << " could not attack because he died" << std::endl; - else + else if (this->_energyPoints <= 0) + std::cout << "ClapTrap " << this->_name << " could not attack because he don't have energy" << std::endl; + else + { std::cout << "ClapTrap " << this->_name << " attacks " << target << ", causing " << this->_attackDamage << " points of damage!" << std::endl; + this->_energyPoints--; + } } void ClapTrap::takeDamage(unsigned int amount) @@ -107,11 +92,21 @@ void ClapTrap::takeDamage(unsigned int amount) else if (this->_hitPoints - amount <= 0) std::cout << "ClapTrap " << this->_name << " died" << std::endl; this->_hitPoints -= amount; - std::cout << "ClapTrap " << this->_name << " have " << this->_hitPoints << " hit points" << std::endl; + if (this->_hitPoints > 0) + std::cout << "ClapTrap " << this->_name << " have " << this->_hitPoints << " hit points" << std::endl; } void ClapTrap::beRepaired(unsigned int amount) { - std::cout << "ClapTrap " << this->_name << " regain " << amount << " hit point(s)!" << std::endl; - this->_hitPoints += amount; + if (this->_hitPoints <= 0) + std::cout << "ClapTrap " << this->_name << " could not repair because he died" << std::endl; + else if (this->_energyPoints <= 0) + std::cout << "ClapTrap " << this->_name << " could not repair because he don't have energy" << std::endl; + else + { + std::cout << "ClapTrap " << this->_name << " regain " << amount << " hit point(s)!" << std::endl; + this->_hitPoints += amount; + std::cout << "ClapTrap " << this->_name << " have " << this->_hitPoints << " hit points" << std::endl; + this->_energyPoints--; + } } diff --git a/cpp03/ex01/ClapTrap.hpp b/cpp03/ex01/ClapTrap.hpp index 4e19760..c62fd62 100644 --- a/cpp03/ex01/ClapTrap.hpp +++ b/cpp03/ex01/ClapTrap.hpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/13 05:22:53 by apommier #+# #+# */ -/* Updated: 2022/07/13 13:13:24 by apommier ### ########.fr */ +/* Updated: 2022/08/01 13:23:39 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,17 +32,12 @@ class ClapTrap { int getEnergyPoints(void) const; int getAttackDamage(void) const; - /*std::string setName(std::string name); - int setHitPoints(int hitPoints); - int setEnergyPoints(int energyPoints); - int setAttackDamage(int attackDamage);*/ - protected: std::string _name; - int _hitPoints = 100; - int _energyPoints = 50; - int _attackDamage = 20; + int _hitPoints; + int _energyPoints; + int _attackDamage; }; #endif \ No newline at end of file diff --git a/cpp03/ex01/main.cpp b/cpp03/ex01/main.cpp index 9d63fec..7f40b2d 100644 --- a/cpp03/ex01/main.cpp +++ b/cpp03/ex01/main.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/13 05:22:55 by apommier #+# #+# */ -/* Updated: 2022/07/13 12:06:07 by apommier ### ########.fr */ +/* Updated: 2022/08/01 19:48:51 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,22 +16,49 @@ int main() { ClapTrap John("John"); - ScavTrap ScavJohn("CL4P-TP"); John.attack("Jean"); John.takeDamage(5); John.takeDamage(4); John.takeDamage(1); - John.takeDamage(1); John.attack("Jean"); + John.beRepaired(100); + + std::cout << std::endl; + ClapTrap John2(John); + John2.attack("Jean"); + John2.takeDamage(5); + John2.beRepaired(100); + + std::cout << std::endl; + ClapTrap John3("John3"); + John3.beRepaired(100); + John3.attack("Jean"); + John3.beRepaired(100); + John3.attack("Jean"); + John3.beRepaired(100); + John3.attack("Jean"); + John3.beRepaired(100); + John3.attack("Jean"); + John3.beRepaired(100); + John3.attack("Jean"); + std::cout << std::endl; + John3.beRepaired(100); + John3.attack("Jean"); + John3.takeDamage(100); + + std::cout << std::endl << "ScavTrap turn\n"; + ScavTrap ScavJohn("CL4P-TP"); ScavJohn.guardGate(); ScavJohn.attack("Jean"); ScavJohn.takeDamage(5); ScavJohn.takeDamage(4); ScavJohn.takeDamage(1); - ScavJohn.takeDamage(1); ScavJohn.attack("Jean"); - + ScavJohn.beRepaired(100); + std::cout <<"ScavTrap have " << ScavJohn.getEnergyPoints() << " energy point(s)\n\n"; + return (0); -} \ No newline at end of file +} + diff --git a/cpp03/ex02/ClapTrap.cpp b/cpp03/ex02/ClapTrap.cpp index a68f893..5ef8f90 100644 --- a/cpp03/ex02/ClapTrap.cpp +++ b/cpp03/ex02/ClapTrap.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/13 05:22:49 by apommier #+# #+# */ -/* Updated: 2022/07/14 01:23:11 by apommier ### ########.fr */ +/* Updated: 2022/08/01 13:13:20 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -69,34 +69,19 @@ int ClapTrap::getAttackDamage(void) const return (this->_attackDamage); } -/*std::string ClapTrap::setName(std::string name) -{ - this->_name = name; -} - -void ClapTrap::setHitPoints(int hitPoints) -{ - this->_hitPoints = hitPoints; -} - -void ClapTrap::setEnergyPoints(int energyPoints) -{ - this->_energyPoints = energyPoints; -} - -void ClapTrap::setAttackDamage(int attackDamage) -{ - this->_attackDamage = attackDamage; -}*/ - //member function void ClapTrap::attack(const std::string& target) { if (this->_hitPoints <= 0) std::cout << "ClapTrap " << this->_name << " could not attack because he died" << std::endl; - else + else if (this->_energyPoints <= 0) + std::cout << "ClapTrap " << this->_name << " could not attack because he don't have energy" << std::endl; + else + { std::cout << "ClapTrap " << this->_name << " attacks " << target << ", causing " << this->_attackDamage << " points of damage!" << std::endl; + this->_energyPoints--; + } } void ClapTrap::takeDamage(unsigned int amount) @@ -107,11 +92,22 @@ void ClapTrap::takeDamage(unsigned int amount) else if (this->_hitPoints - amount <= 0) std::cout << "ClapTrap " << this->_name << " died" << std::endl; this->_hitPoints -= amount; - std::cout << "ClapTrap " << this->_name << " have " << this->_hitPoints << " hit points" << std::endl; + if (this->_hitPoints > 0) + std::cout << "ClapTrap " << this->_name << " have " << this->_hitPoints << " hit points" << std::endl; } void ClapTrap::beRepaired(unsigned int amount) { - std::cout << "ClapTrap " << this->_name << " regain " << amount << " hit point(s)!" << std::endl; - this->_hitPoints += amount; + if (this->_hitPoints <= 0) + std::cout << "ClapTrap " << this->_name << " could not repair because he died" << std::endl; + else if (this->_energyPoints <= 0) + std::cout << "ClapTrap " << this->_name << " could not repair because he don't have energy" << std::endl; + else + { + std::cout << "ClapTrap " << this->_name << " regain " << amount << " hit point(s)!" << std::endl; + this->_hitPoints += amount; + std::cout << "ClapTrap " << this->_name << " have " << this->_hitPoints << " hit points" << std::endl; + this->_energyPoints--; + } } + diff --git a/cpp03/ex02/ClapTrap.hpp b/cpp03/ex02/ClapTrap.hpp index 6af74c9..96757dc 100644 --- a/cpp03/ex02/ClapTrap.hpp +++ b/cpp03/ex02/ClapTrap.hpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/13 05:22:53 by apommier #+# #+# */ -/* Updated: 2022/07/18 22:57:33 by apommier ### ########.fr */ +/* Updated: 2022/08/01 13:23:33 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,17 +32,12 @@ class ClapTrap { int getEnergyPoints(void) const; int getAttackDamage(void) const; - /*std::string setName(std::string name); - int setHitPoints(int hitPoints); - int setEnergyPoints(int energyPoints); - int setAttackDamage(int attackDamage);*/ - protected: std::string _name; - int _hitPoints = 100; - int _energyPoints = 50; - int _attackDamage = 20; + int _hitPoints; + int _energyPoints; + int _attackDamage; }; #endif \ No newline at end of file diff --git a/cpp03/ex02/main.cpp b/cpp03/ex02/main.cpp index d43dbaf..6c0b834 100644 --- a/cpp03/ex02/main.cpp +++ b/cpp03/ex02/main.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/13 05:22:55 by apommier #+# #+# */ -/* Updated: 2022/07/14 01:58:00 by apommier ### ########.fr */ +/* Updated: 2022/08/01 22:12:59 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,21 +22,45 @@ int main() John.takeDamage(5); John.takeDamage(4); John.takeDamage(1); - John.takeDamage(1); John.attack("Jean"); + John.beRepaired(100); std::cout << std::endl; + ClapTrap John2(John); + John2.attack("Jean"); + John2.takeDamage(5); + John2.beRepaired(100); + + std::cout << std::endl; + ClapTrap John3("John3"); + John3.beRepaired(100); + John3.attack("Jean"); + John3.beRepaired(100); + John3.attack("Jean"); + John3.beRepaired(100); + John3.attack("Jean"); + John3.beRepaired(100); + John3.attack("Jean"); + John3.beRepaired(100); + John3.attack("Jean"); + std::cout << std::endl; + John3.beRepaired(100); + John3.attack("Jean"); + John3.takeDamage(100); + + std::cout << std::endl << "ScavTrap turn\n"; ScavTrap ScavJohn("CL4P-TP"); - + ScavJohn.guardGate(); ScavJohn.attack("Jean"); ScavJohn.takeDamage(5); ScavJohn.takeDamage(4); ScavJohn.takeDamage(1); - ScavJohn.takeDamage(1); ScavJohn.attack("Jean"); + ScavJohn.beRepaired(100); + std::cout <<"ScavTrap have " << ScavJohn.getEnergyPoints() << " energy point(s)\n\n"; - std::cout << std::endl; + std::cout << std::endl << "FragTrap turn\n"; FragTrap FragJohn("Assassin"); FragJohn.highFivesGuys(); @@ -46,6 +70,44 @@ int main() FragJohn.takeDamage(1); FragJohn.takeDamage(1); FragJohn.attack("Jean"); - + std::cout <<"ScavTrap have " << FragJohn.getEnergyPoints() << " energy point(s)\n\n"; + std::cout << std::endl; + return (0); -} \ No newline at end of file +} + +// int main() +// { +// ClapTrap John("John"); + +// John.attack("Jean"); +// John.takeDamage(5); +// John.takeDamage(4); +// John.takeDamage(1); +// John.takeDamage(1); +// John.attack("Jean"); + +// std::cout << std::endl; +// ScavTrap ScavJohn("CL4P-TP"); + +// ScavJohn.guardGate(); +// ScavJohn.attack("Jean"); +// ScavJohn.takeDamage(5); +// ScavJohn.takeDamage(4); +// ScavJohn.takeDamage(1); +// ScavJohn.takeDamage(1); +// ScavJohn.attack("Jean"); + +// std::cout << std::endl; +// FragTrap FragJohn("Assassin"); + +// FragJohn.highFivesGuys(); +// FragJohn.attack("Jean"); +// FragJohn.takeDamage(5); +// FragJohn.takeDamage(4); +// FragJohn.takeDamage(1); +// FragJohn.takeDamage(1); +// FragJohn.attack("Jean"); + +// return (0); +// } \ No newline at end of file