From 3606af64b42ced920eeb029a75b7c7abcf4e54ba Mon Sep 17 00:00:00 2001 From: narnaud Date: Tue, 19 Jul 2022 08:40:31 +0200 Subject: [PATCH] bonus cpp03 --- CPP03/ex00/ClapTrap.cpp | 23 ++++----- CPP03/ex00/ClapTrap.hpp | 8 +--- CPP03/ex01/ClapTrap.cpp | 4 +- CPP03/ex01/ClapTrap.hpp | 6 +-- CPP03/ex01/ScavTrap.cpp | 7 ++- CPP03/ex01/ScavTrap.hpp | 8 +--- CPP03/ex01/claptrap | Bin 33588 -> 0 bytes CPP03/ex02/ClapTrap.cpp | 6 +-- CPP03/ex02/ClapTrap.hpp | 8 +--- CPP03/ex02/FragTrap.cpp | 7 ++- CPP03/ex02/FragTrap.hpp | 8 +--- CPP03/ex02/ScavTrap.cpp | 7 ++- CPP03/ex02/ScavTrap.hpp | 8 +--- CPP03/ex02/claptrap | Bin 33588 -> 0 bytes CPP03/ex03/ClapTrap.cpp | 96 +++++++++++++++++++++++++++++++++++++ CPP03/ex03/ClapTrap.hpp | 45 +++++++++++++++++ CPP03/ex03/DiamondTrap.cpp | 41 ++++++++++++++++ CPP03/ex03/DiamondTrap.hpp | 24 ++++++++++ CPP03/ex03/FragTrap.cpp | 43 +++++++++++++++++ CPP03/ex03/FragTrap.hpp | 23 +++++++++ CPP03/ex03/Makefile | 20 ++++++++ CPP03/ex03/ScavTrap.cpp | 43 +++++++++++++++++ CPP03/ex03/ScavTrap.hpp | 24 ++++++++++ CPP03/ex03/main.cpp | 30 ++++++++++++ 24 files changed, 429 insertions(+), 60 deletions(-) delete mode 100755 CPP03/ex01/claptrap delete mode 100755 CPP03/ex02/claptrap create mode 100644 CPP03/ex03/ClapTrap.cpp create mode 100644 CPP03/ex03/ClapTrap.hpp create mode 100644 CPP03/ex03/DiamondTrap.cpp create mode 100644 CPP03/ex03/DiamondTrap.hpp create mode 100644 CPP03/ex03/FragTrap.cpp create mode 100644 CPP03/ex03/FragTrap.hpp create mode 100644 CPP03/ex03/Makefile create mode 100644 CPP03/ex03/ScavTrap.cpp create mode 100644 CPP03/ex03/ScavTrap.hpp create mode 100644 CPP03/ex03/main.cpp diff --git a/CPP03/ex00/ClapTrap.cpp b/CPP03/ex00/ClapTrap.cpp index e07c0c5..34c19c2 100644 --- a/CPP03/ex00/ClapTrap.cpp +++ b/CPP03/ex00/ClapTrap.cpp @@ -6,7 +6,7 @@ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/23 10:53:50 by narnaud #+# #+# */ -/* Updated: 2022/06/23 17:47:34 by narnaud ### ########.fr */ +/* Updated: 2022/07/19 02:12:17 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,17 +16,14 @@ int ClapTrap::amount = 0; ClapTrap *ClapTrap::registery[128] = {NULL}; -ClapTrap::ClapTrap (void) { +ClapTrap::ClapTrap (void) {} - std::cout << "ClapTrap default constructor called " << endl; -} - -ClapTrap::ClapTrap (std::string name, size_t hp, size_t ep, size_t atk) - : _name(name), _health(hp), _energy(ep), _attack(atk) { +ClapTrap::ClapTrap (std::string name) + : _name(name), _health(10), _energy(10), _attack(0) { if (ClapTrap::amount >= 128) { - delete ClapTrap::registery[amount % 128]; cout << "There are too many Traps " << ClapTrap::registery[amount % 128]->getName() << " destroyed\n"; + delete ClapTrap::registery[amount % 128]; } cout << "ClapTrap " << name << " was created" << endl; _id = ClapTrap::amount % 128; @@ -39,15 +36,11 @@ ClapTrap::ClapTrap (ClapTrap const & src) { } ClapTrap & ClapTrap::operator= (ClapTrap const & src) { - std::cout << "ClapTrap assignment operator called" << endl; _name = src.getName(); return (*this); } -ClapTrap::~ClapTrap (void) { - - std::cout << "ClapTrap " << _name << " was destroyed" << endl; -} +ClapTrap::~ClapTrap (void) {} void ClapTrap::attack(const std::string& target) { if (_energy == 0 || _health == 0) @@ -87,10 +80,12 @@ std::string ClapTrap::getName(void) const { } ClapTrap *ClapTrap::getClapTrap(std::string name) { - for (int i = 0; i < 128; i++) + int i = 0; + while (i < ClapTrap::amount && i < 128) { if (name == ClapTrap::registery[i]->getName()) return (ClapTrap::registery[i]); + i++; } return (NULL); } diff --git a/CPP03/ex00/ClapTrap.hpp b/CPP03/ex00/ClapTrap.hpp index 4ce8a2e..ea62e02 100644 --- a/CPP03/ex00/ClapTrap.hpp +++ b/CPP03/ex00/ClapTrap.hpp @@ -6,14 +6,11 @@ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/23 10:54:07 by narnaud #+# #+# */ -/* Updated: 2022/06/24 07:50:53 by narnaud ### ########.fr */ +/* Updated: 2022/07/19 02:09:51 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once -#define CT_HEALTH 10 -#define CT_ENERGY 10 -#define CT_DMG 0 #include #include @@ -26,8 +23,7 @@ class ClapTrap { static ClapTrap *registery[128]; static int amount; ClapTrap (void); - ClapTrap (std::string name, size_t hp = CT_HEALTH,\ - size_t ep = CT_ENERGY, size_t atk = CT_DMG); + ClapTrap (std::string name); ClapTrap (ClapTrap const & src); virtual ~ClapTrap (void); ClapTrap & operator= (ClapTrap const & src); diff --git a/CPP03/ex01/ClapTrap.cpp b/CPP03/ex01/ClapTrap.cpp index e07c0c5..b808dd4 100644 --- a/CPP03/ex01/ClapTrap.cpp +++ b/CPP03/ex01/ClapTrap.cpp @@ -21,8 +21,8 @@ ClapTrap::ClapTrap (void) { std::cout << "ClapTrap default constructor called " << endl; } -ClapTrap::ClapTrap (std::string name, size_t hp, size_t ep, size_t atk) - : _name(name), _health(hp), _energy(ep), _attack(atk) { +ClapTrap::ClapTrap (std::string name) + : _name(name), _health(10), _energy(10), _attack(0) { if (ClapTrap::amount >= 128) { delete ClapTrap::registery[amount % 128]; diff --git a/CPP03/ex01/ClapTrap.hpp b/CPP03/ex01/ClapTrap.hpp index 384b1ab..f8d803e 100644 --- a/CPP03/ex01/ClapTrap.hpp +++ b/CPP03/ex01/ClapTrap.hpp @@ -11,9 +11,6 @@ /* ************************************************************************** */ #pragma once -#define CT_HEALTH 10 -#define CT_ENERGY 10 -#define CT_DMG 0 #include #include @@ -26,8 +23,7 @@ class ClapTrap { static ClapTrap *registery[128]; static int amount; ClapTrap (void); - ClapTrap (std::string name, size_t hp = CT_HEALTH,\ - size_t ep = CT_ENERGY, size_t atk = CT_DMG); + ClapTrap (std::string name); ClapTrap (ClapTrap const & src); virtual ~ClapTrap (void); ClapTrap & operator= (ClapTrap const & src); diff --git a/CPP03/ex01/ScavTrap.cpp b/CPP03/ex01/ScavTrap.cpp index bb54637..14dbd82 100644 --- a/CPP03/ex01/ScavTrap.cpp +++ b/CPP03/ex01/ScavTrap.cpp @@ -6,13 +6,16 @@ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/23 15:19:54 by narnaud #+# #+# */ -/* Updated: 2022/06/24 07:49:17 by narnaud ### ########.fr */ +/* Updated: 2022/07/19 02:17:44 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "ScavTrap.hpp" -ScavTrap::ScavTrap (std::string name, size_t hp, size_t ep, size_t atk):ClapTrap(name, hp, ep, atk){ +ScavTrap::ScavTrap (std::string name):ClapTrap(name){ + _health = 100; + _energy= 50; + _attack = 20; cout << "ClapTrap " << name << " evolved to ScavTrap" << endl; } diff --git a/CPP03/ex01/ScavTrap.hpp b/CPP03/ex01/ScavTrap.hpp index 66e1e9b..de29253 100644 --- a/CPP03/ex01/ScavTrap.hpp +++ b/CPP03/ex01/ScavTrap.hpp @@ -6,22 +6,18 @@ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/23 15:17:41 by narnaud #+# #+# */ -/* Updated: 2022/06/23 17:03:22 by narnaud ### ########.fr */ +/* Updated: 2022/07/19 02:16:21 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once #include "ClapTrap.hpp" -#define ST_HEALTH 100 -#define ST_ENERGY 50 -#define ST_DMG 20 class ScavTrap : public ClapTrap { public: - ScavTrap (std::string name, size_t hp = ST_HEALTH,\ - size_t ep = ST_ENERGY, size_t atk = ST_DMG); + ScavTrap (std::string name); ~ScavTrap (void); void attack(const std::string& target); void guardGate(void); diff --git a/CPP03/ex01/claptrap b/CPP03/ex01/claptrap deleted file mode 100755 index 4857b0e3f7310ddf0af63abf6fb83e067e2d8d18..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 33588 zcmeHw34B!5z5ltBL=qM!id9^>C@8q#1PFvG8icEZ5IVA0mxq%{GLYCTV`hTTXLN9g zFT)s2-HNsK<+;7oHP5;PTX;bcc(&EC)z@?%t=c;+wfR^Tu++To?<{xjEI|Z(|K*eW z;V$2Ee&=_7=XZYRch(HAfBKitMlh!3F&1_(#)@%=k7BGXJON*forv3w+w1krz0A1A zSn@RrO~15sm=h77HORp0U1nUhES-d>FHa9+5*HwtZpg?luQ%jh6OsV0On#m*C=9}D z&Ji?(^Hbym!glEO216}XK`SVe-?L?c-;0t$VU?gz@`K9wCHQ%3{q+HVGeR=?1!fC= zpGbPbq<8Del5bUYwb#F<+8+pcL%ym^ezji}{N9vI2&eJ07>f_Dw>lVVu4`N+!!!9^ zI7jfCB`cM%{mSGGeoc+RRE1>n3tlAn9VeL(KG5a$wlv;Y*I47NYh2j`!c2bclHVFB zAK^@y?EJ~@`a$dU&Y!z%t}Uiq$i)qwf`R!(4FDI~1HZ}k=<<3S>%GCX4OLC`-ax2% zNPdNaobw|d>LU9XuK?a&@2aMh*0SX*EEn?WG7aHOekzVgyxw}>f#jQv^rW)AM2w5D zogcNYi4-BP?0QYtpAKCTzcrGcu$`acqu#`?p`ocUh12(1tyv4R@dopcP;`*M^#^pw~6;&dV?^r1W^#g^>xO& zU<_ny<8armV2pgiao01ZLzq$cMiPFl#*^+daeo*0X}E{F3hNk~mm~6Mgz30P<37J7 z*nEC{UDf$DYwK%(={gxV$uYh5FHb!E6fkzhWrgvFOf+=Ep$Zk#Q%x0O?Xei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8056078 100644 --- a/CPP03/ex02/ClapTrap.cpp +++ b/CPP03/ex02/ClapTrap.cpp @@ -6,7 +6,7 @@ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/23 10:53:50 by narnaud #+# #+# */ -/* Updated: 2022/06/23 17:47:34 by narnaud ### ########.fr */ +/* Updated: 2022/07/19 02:20:18 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,8 +21,8 @@ ClapTrap::ClapTrap (void) { std::cout << "ClapTrap default constructor called " << endl; } -ClapTrap::ClapTrap (std::string name, size_t hp, size_t ep, size_t atk) - : _name(name), _health(hp), _energy(ep), _attack(atk) { +ClapTrap::ClapTrap (std::string name) + : _name(name), _health(10), _energy(10), _attack(0) { if (ClapTrap::amount >= 128) { delete ClapTrap::registery[amount % 128]; diff --git a/CPP03/ex02/ClapTrap.hpp b/CPP03/ex02/ClapTrap.hpp index a4271bc..2664539 100644 --- a/CPP03/ex02/ClapTrap.hpp +++ b/CPP03/ex02/ClapTrap.hpp @@ -6,14 +6,11 @@ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/23 10:54:07 by narnaud #+# #+# */ -/* Updated: 2022/06/24 07:51:21 by narnaud ### ########.fr */ +/* Updated: 2022/07/19 02:19:51 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once -#define CT_HEALTH 10 -#define CT_ENERGY 10 -#define CT_DMG 0 #include #include @@ -26,8 +23,7 @@ class ClapTrap { static ClapTrap *registery[128]; static int amount; ClapTrap (void); - ClapTrap (std::string name, size_t hp = CT_HEALTH,\ - size_t ep = CT_ENERGY, size_t atk = CT_DMG); + ClapTrap (std::string name); ClapTrap (ClapTrap const & src); virtual ~ClapTrap (void); ClapTrap & operator= (ClapTrap const & src); diff --git a/CPP03/ex02/FragTrap.cpp b/CPP03/ex02/FragTrap.cpp index ceb544e..27b0202 100644 --- a/CPP03/ex02/FragTrap.cpp +++ b/CPP03/ex02/FragTrap.cpp @@ -6,13 +6,16 @@ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/23 15:19:54 by narnaud #+# #+# */ -/* Updated: 2022/06/24 07:46:44 by narnaud ### ########.fr */ +/* Updated: 2022/07/19 02:23:22 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "FragTrap.hpp" -FragTrap::FragTrap (std::string name, size_t hp, size_t ep, size_t atk):ClapTrap(name, hp, ep, atk){ +FragTrap::FragTrap (std::string name):ClapTrap(name){ + _health = 100; + _energy = 100; + _attack = 30; cout << "ClapTrap " << name << " evolved to FragTrap" << endl; } diff --git a/CPP03/ex02/FragTrap.hpp b/CPP03/ex02/FragTrap.hpp index 904cf21..8f81c1c 100644 --- a/CPP03/ex02/FragTrap.hpp +++ b/CPP03/ex02/FragTrap.hpp @@ -6,22 +6,18 @@ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/23 15:17:41 by narnaud #+# #+# */ -/* Updated: 2022/06/24 07:33:33 by narnaud ### ########.fr */ +/* Updated: 2022/07/19 02:23:55 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once #include "ClapTrap.hpp" -#define FT_HEALTH 100 -#define FT_ENERGY 100 -#define FT_DMG 30 class FragTrap : public ClapTrap { public: - FragTrap (std::string name, size_t hp = FT_HEALTH,\ - size_t ep = FT_ENERGY, size_t atk = FT_DMG); + FragTrap (std::string name); ~FragTrap (void); void attack(const std::string& target); void highFivesGuys(void); diff --git a/CPP03/ex02/ScavTrap.cpp b/CPP03/ex02/ScavTrap.cpp index 71a46c5..df0e28a 100644 --- a/CPP03/ex02/ScavTrap.cpp +++ b/CPP03/ex02/ScavTrap.cpp @@ -6,13 +6,16 @@ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/23 15:19:54 by narnaud #+# #+# */ -/* Updated: 2022/06/24 07:47:54 by narnaud ### ########.fr */ +/* Updated: 2022/07/19 02:22:09 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "ScavTrap.hpp" -ScavTrap::ScavTrap (std::string name, size_t hp, size_t ep, size_t atk):ClapTrap(name, hp, ep, atk){ +ScavTrap::ScavTrap (std::string name):ClapTrap(name){ + _health = 100; + _energy = 50; + _attack = 20; cout << "ClapTrap " << name << " evolved to ScavTrap" << endl; } diff --git a/CPP03/ex02/ScavTrap.hpp b/CPP03/ex02/ScavTrap.hpp index 66e1e9b..ec8310d 100644 --- a/CPP03/ex02/ScavTrap.hpp +++ b/CPP03/ex02/ScavTrap.hpp @@ -6,22 +6,18 @@ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/23 15:17:41 by narnaud #+# #+# */ -/* Updated: 2022/06/23 17:03:22 by narnaud ### ########.fr */ +/* Updated: 2022/07/19 02:24:27 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once #include "ClapTrap.hpp" -#define ST_HEALTH 100 -#define ST_ENERGY 50 -#define ST_DMG 20 class ScavTrap : public ClapTrap { public: - ScavTrap (std::string name, size_t hp = ST_HEALTH,\ - size_t ep = ST_ENERGY, size_t atk = ST_DMG); + ScavTrap (std::string name); ~ScavTrap (void); void attack(const std::string& target); void guardGate(void); diff --git a/CPP03/ex02/claptrap b/CPP03/ex02/claptrap deleted file mode 100755 index 4857b0e3f7310ddf0af63abf6fb83e067e2d8d18..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 33588 zcmeHw34B!5z5ltBL=qM!id9^>C@8q#1PFvG8icEZ5IVA0mxq%{GLYCTV`hTTXLN9g zFT)s2-HNsK<+;7oHP5;PTX;bcc(&EC)z@?%t=c;+wfR^Tu++To?<{xjEI|Z(|K*eW z;V$2Ee&=_7=XZYRch(HAfBKitMlh!3F&1_(#)@%=k7BGXJON*forv3w+w1krz0A1A zSn@RrO~15sm=h77HORp0U1nUhES-d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>bw?} zh&uMBIwIlLWI0nERP}1lGB5X^rPj$r9Iiy&3{gn*XlblcD!Z|+1_wj!?z7||d6ouY zGL6(z*4qkkXvU7ZmcwRc*@x8E&8YE(d})QrET~=7ls=Jt1)bo5{&CRDsI!&FMl@|m zqC+h7G*xKfJr_}n3^jS1eK&doO*jGUZ(gtvXH-$wbSBSc@rRaQ3696Xg(%+X7IA1S zXXDIh&|BZsxavr7D=8BK62BuUWeLQjf(L7xnujX>moyei>nfye|1b9yvTL3pO-da! zN4qsjTvlKc4t|!{UG<{bzM2{ufi|sFR=5PN*VZ(?h?_(oe{jzHbA4xNa}E4ly1AuV zd5*}>=LjF@Z^YSKn=4M8#U?jv&EDv|_`+r4RJfeFrFBIXVQDr`OUO*`e|Ro0Socjj zyLtHDL3Td8@f|Uy@Mx))C%IlWZyt`UR{I0^69->az2C($LuO@#l$2x#P0tRRksUNM pJ1Cp|^lbLivw4-y&f+yQn`%}zuhOh^*_=wU)i5KQ`Hb0&{SQDeiTwZo diff --git a/CPP03/ex03/ClapTrap.cpp b/CPP03/ex03/ClapTrap.cpp new file mode 100644 index 0000000..71d4ee5 --- /dev/null +++ b/CPP03/ex03/ClapTrap.cpp @@ -0,0 +1,96 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ClapTrap.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/23 10:53:50 by narnaud #+# #+# */ +/* Updated: 2022/07/19 02:26:32 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "ClapTrap.hpp" + +int ClapTrap::amount = 0; +ClapTrap *ClapTrap::registery[128] = {NULL}; + + +ClapTrap::ClapTrap (void) { + + std::cout << "ClapTrap default constructor called " << endl; +} + +ClapTrap::ClapTrap (std::string name) + : _name(name), _health(10), _energy(10), _attack(0) { + if (ClapTrap::amount >= 128) + { + delete ClapTrap::registery[amount % 128]; + cout << "There are too many Traps " << ClapTrap::registery[amount % 128]->getName() << " destroyed\n"; + } + cout << "ClapTrap " << name << " was created" << endl; + _id = ClapTrap::amount % 128; + ClapTrap::registery[ClapTrap::amount % 128] = this; + ClapTrap::amount++; +} + +ClapTrap::ClapTrap (ClapTrap const & src) { + _name = src.getName(); +} + +ClapTrap & ClapTrap::operator= (ClapTrap const & src) { + std::cout << "ClapTrap assignment operator called" << endl; + _name = src.getName(); + return (*this); +} + +ClapTrap::~ClapTrap (void) { + + std::cout << "ClapTrap " << _name << " was destroyed" << endl; +} + +void ClapTrap::attack(const std::string& target) { + if (_energy == 0 || _health == 0) + cout << _name << " is no more able to attack anyone" << endl; + else + { + cout << _name << " attacked " << target << endl; + getClapTrap(target)->takeDamage(_attack); + _energy--; + } +} + +void ClapTrap::takeDamage(unsigned int amount) { + if (_health == 0) + cout << _name << " is already death" << endl; + else + cout << _name << " lose " << amount << " hp" << endl; + if (amount >= _health) + _health = 0; + else + _health -= amount; +} + +void ClapTrap::beRepaired(unsigned int amount) { + if (_energy == 0 || _health == 0) + cout << _name << " is no more able to repair anyone" << endl; + else + { + cout << _name << " was repaired for " << amount << " hp" << endl; + _health += amount; + _energy--; + } +} + +std::string ClapTrap::getName(void) const { + return (_name); +} + +ClapTrap *ClapTrap::getClapTrap(std::string name) { + for (int i = 0; i < 128; i++) + { + if (name == ClapTrap::registery[i]->getName()) + return (ClapTrap::registery[i]); + } + return (NULL); +} diff --git a/CPP03/ex03/ClapTrap.hpp b/CPP03/ex03/ClapTrap.hpp new file mode 100644 index 0000000..7f1c8af --- /dev/null +++ b/CPP03/ex03/ClapTrap.hpp @@ -0,0 +1,45 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ClapTrap.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/23 10:54:07 by narnaud #+# #+# */ +/* Updated: 2022/07/19 02:49:28 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once + +#include +#include +using std::cout; +using std::endl; + +class ClapTrap { + + public: + static ClapTrap *registery[128]; + static int amount; + + ClapTrap (void); + ClapTrap (std::string name); + ClapTrap (ClapTrap const & src); + virtual ~ClapTrap (void); + + ClapTrap & operator= (ClapTrap const & src); + + virtual void attack(const std::string& target); + void takeDamage(unsigned int amount); + void beRepaired(unsigned int amount); + std::string getName(void) const; + static ClapTrap *getClapTrap(std::string name); + + protected: + std::string _name; + unsigned int _health; + unsigned int _energy; + unsigned int _attack; + unsigned int _id; +}; diff --git a/CPP03/ex03/DiamondTrap.cpp b/CPP03/ex03/DiamondTrap.cpp new file mode 100644 index 0000000..c09efc3 --- /dev/null +++ b/CPP03/ex03/DiamondTrap.cpp @@ -0,0 +1,41 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* DiamondTrap.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/23 15:19:54 by narnaud #+# #+# */ +/* Updated: 2022/07/19 02:45:31 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "DiamondTrap.hpp" + +DiamondTrap::DiamondTrap (std::string name): ScavTrap(name), FragTrap(name){ + ClapTrap::_name = name + "_clap_name"; + _name = name; + _health = FragTrap::_health; + _energy = ScavTrap::_energy; + _attack = FragTrap::_attack; + cout << name << "is now a DiamondTrap" << endl; +} + +DiamondTrap::~DiamondTrap (void) { + cout << "DiamondTrap " << _name << " was destroyed" << endl; +} + +void DiamondTrap::attack(const std::string& target) { + if (_energy == 0 || _health == 0) + cout << _name << " is no more able to attack" << endl; + else + { + cout << _name << " heavily attacked " << target << endl; + getClapTrap(target)->takeDamage(_attack); + _energy--; + } +} + +void DiamondTrap::whoAmI(void) { + cout << "Name: " << _name << " - Clap name: " << ClapTrap::_name << endl; +} diff --git a/CPP03/ex03/DiamondTrap.hpp b/CPP03/ex03/DiamondTrap.hpp new file mode 100644 index 0000000..b3886ac --- /dev/null +++ b/CPP03/ex03/DiamondTrap.hpp @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* DiamondTrap.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/23 15:17:41 by narnaud #+# #+# */ +/* Updated: 2022/07/19 02:52:31 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once +#include "ScavTrap.hpp" +#include "FragTrap.hpp" + +class DiamondTrap : public ScavTrap, public FragTrap { + std::string _name; + public: + DiamondTrap (std::string name); + ~DiamondTrap (void); + void attack(const std::string& target); + void whoAmI(void); +}; diff --git a/CPP03/ex03/FragTrap.cpp b/CPP03/ex03/FragTrap.cpp new file mode 100644 index 0000000..1bfa0b1 --- /dev/null +++ b/CPP03/ex03/FragTrap.cpp @@ -0,0 +1,43 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* FragTrap.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/23 15:19:54 by narnaud #+# #+# */ +/* Updated: 2022/07/19 02:29:38 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "FragTrap.hpp" + +FragTrap::FragTrap (std::string name):ClapTrap(name){ + _health = 100; + _energy = 100; + _attack = 30; + cout << "ClapTrap " << name << " evolved to FragTrap" << endl; +} + +FragTrap::~FragTrap (void) { + cout << "FragTrap " << _name << " was destroyed" << endl; +} + +void FragTrap::attack(const std::string& target) { + if (_energy == 0 || _health == 0) + cout << _name << " is no more able to attack anyone"; + else + { + cout << _name << " hardly attacked " << target << endl; + getClapTrap(target)->takeDamage(_attack); + _energy--; + } +} + +void FragTrap::highFivesGuys(void) { + for (int i = 0; i < 128; i++) + { + if (ClapTrap::registery[i]) + cout << _name << " high five " << ClapTrap::registery[i]->getName() << endl; + } +} diff --git a/CPP03/ex03/FragTrap.hpp b/CPP03/ex03/FragTrap.hpp new file mode 100644 index 0000000..a163147 --- /dev/null +++ b/CPP03/ex03/FragTrap.hpp @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* FragTrap.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/23 15:17:41 by narnaud #+# #+# */ +/* Updated: 2022/07/19 02:49:59 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once +#include "ClapTrap.hpp" + +class FragTrap : virtual public ClapTrap { + + public: + FragTrap (std::string name); + ~FragTrap (void); + void attack(const std::string& target); + void highFivesGuys(void); +}; diff --git a/CPP03/ex03/Makefile b/CPP03/ex03/Makefile new file mode 100644 index 0000000..f4ff839 --- /dev/null +++ b/CPP03/ex03/Makefile @@ -0,0 +1,20 @@ +NAME = diamondtrap +SRCS = main.cpp ClapTrap.cpp ScavTrap.cpp FragTrap.cpp DiamondTrap.cpp +OBJS = $(SRCS:.cpp=.o) + +CXXFLAGS = -std=c++98 -Werror -Wextra -Wall + +$(NAME): $(OBJS) + c++ $(OBJS) -o $(NAME) + +all : $(NAME) + +clean : + rm -rf $(OBJS) + +fclean : clean + rm -rf $(NAME) + +re : fclean all + +.PHONY: all clean fclean re diff --git a/CPP03/ex03/ScavTrap.cpp b/CPP03/ex03/ScavTrap.cpp new file mode 100644 index 0000000..44fb426 --- /dev/null +++ b/CPP03/ex03/ScavTrap.cpp @@ -0,0 +1,43 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ScavTrap.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/23 15:19:54 by narnaud #+# #+# */ +/* Updated: 2022/07/19 02:27:49 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "ScavTrap.hpp" + +ScavTrap::ScavTrap (std::string name) +:ClapTrap(name){ + _health = 100; + _energy = 50; + _attack = 20; + cout << "ClapTrap " << name << " evolved to ScavTrap" << endl; +} + +ScavTrap::~ScavTrap (void) { + cout << "ScavTrap " << _name << " was destroyed" << endl; +} + +void ScavTrap::attack(const std::string& target) { + if (_energy == 0 || _health == 0) + cout << _name << " is no more able to attack" << endl; + else + { + cout << _name << " heavily attacked " << target << endl; + getClapTrap(target)->takeDamage(_attack); + _energy--; + } +} + +void ScavTrap::guardGate(void) { + if (_health == 0) + cout << _name << " is no more able to guard" << endl; + else + cout << _name << " is now in guard gate mode.\n"; +} diff --git a/CPP03/ex03/ScavTrap.hpp b/CPP03/ex03/ScavTrap.hpp new file mode 100644 index 0000000..a4758d4 --- /dev/null +++ b/CPP03/ex03/ScavTrap.hpp @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ScavTrap.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/23 15:17:41 by narnaud #+# #+# */ +/* Updated: 2022/07/19 02:27:07 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once +#include "ClapTrap.hpp" + +class ScavTrap : virtual public ClapTrap { + + public: + + ScavTrap (std::string name); + ~ScavTrap (void); + void attack(const std::string& target); + void guardGate(void); +}; diff --git a/CPP03/ex03/main.cpp b/CPP03/ex03/main.cpp new file mode 100644 index 0000000..7c827eb --- /dev/null +++ b/CPP03/ex03/main.cpp @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: narnaud +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/06/23 10:53:16 by narnaud #+# #+# */ +/* Updated: 2022/07/19 02:47:30 by narnaud ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "ScavTrap.hpp" +#include "FragTrap.hpp" +#include "DiamondTrap.hpp" + +int main(void) +{ + ClapTrap a("A"); + ScavTrap b("B"); + FragTrap c("C"); + DiamondTrap d("D"); + + a.attack("B"); + b.attack("C"); + c.attack("B"); + c.highFivesGuys(); + d.attack("C"); + d.whoAmI(); +}