diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-12-11 12:11:50 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-12-11 12:11:50 +0100 |
| commit | c10aa969c60cedef893146307fa319250901465a (patch) | |
| tree | e3dfa785191047ee8e2ed533f963fe7c5cd7aacf /cpp04/ex01 | |
| parent | 6169d697a5be59426d034b878bffc848de49491d (diff) | |
| download | piscine_cpp-c10aa969c60cedef893146307fa319250901465a.tar.gz piscine_cpp-c10aa969c60cedef893146307fa319250901465a.tar.bz2 piscine_cpp-c10aa969c60cedef893146307fa319250901465a.zip | |
Fixing cpp04 according to correction
Diffstat (limited to 'cpp04/ex01')
| -rw-r--r-- | cpp04/ex01/PlasmaRifle.cpp | 21 | ||||
| -rw-r--r-- | cpp04/ex01/PlasmaRifle.hpp | 16 | ||||
| -rw-r--r-- | cpp04/ex01/PowerFist.hpp | 4 | ||||
| -rw-r--r-- | cpp04/ex01/RadScorpion.cpp | 25 | ||||
| -rw-r--r-- | cpp04/ex01/RadScorpion.hpp | 13 | ||||
| -rw-r--r-- | cpp04/ex01/main.cpp | 30 |
6 files changed, 101 insertions, 8 deletions
diff --git a/cpp04/ex01/PlasmaRifle.cpp b/cpp04/ex01/PlasmaRifle.cpp index fc6bddd..df06864 100644 --- a/cpp04/ex01/PlasmaRifle.cpp +++ b/cpp04/ex01/PlasmaRifle.cpp @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 13:07:24 by charles #+# #+# */ -/* Updated: 2020/11/12 13:35:36 by cacharle ### ########.fr */ +/* Updated: 2020/12/11 10:56:23 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,3 +28,22 @@ void PlasmaRifle::attack() const { std::cout << "* piouuu piouuu piouuu *" << std::endl; } + +/******************************************************************************/ + +ThisIsNotAPlasmaRifle::ThisIsNotAPlasmaRifle() : AWeapon("Not a Plasma Rifle", 5, 21) {} + +ThisIsNotAPlasmaRifle::ThisIsNotAPlasmaRifle(ThisIsNotAPlasmaRifle const& other) : AWeapon(other) {} + +ThisIsNotAPlasmaRifle& ThisIsNotAPlasmaRifle::operator=(ThisIsNotAPlasmaRifle const& other) +{ + AWeapon::operator=(other); + return *this; +} + +ThisIsNotAPlasmaRifle::~ThisIsNotAPlasmaRifle() {} + +void ThisIsNotAPlasmaRifle::attack() const +{ + std::cout << "* not piouuu piouuu piouuu *" << std::endl; +} diff --git a/cpp04/ex01/PlasmaRifle.hpp b/cpp04/ex01/PlasmaRifle.hpp index 8ce7b0d..53088a9 100644 --- a/cpp04/ex01/PlasmaRifle.hpp +++ b/cpp04/ex01/PlasmaRifle.hpp @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 12:15:47 by charles #+# #+# */ -/* Updated: 2020/11/12 13:36:55 by cacharle ### ########.fr */ +/* Updated: 2020/12/11 10:55:04 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,12 +22,24 @@ public: PlasmaRifle(); PlasmaRifle(PlasmaRifle const& other); PlasmaRifle& operator=(PlasmaRifle const& other); - ~PlasmaRifle(); + virtual ~PlasmaRifle(); virtual void attack() const; private: }; +class ThisIsNotAPlasmaRifle : public AWeapon +{ +public: + ThisIsNotAPlasmaRifle(); + ThisIsNotAPlasmaRifle(ThisIsNotAPlasmaRifle const& other); + ThisIsNotAPlasmaRifle& operator=(ThisIsNotAPlasmaRifle const& other); + virtual ~ThisIsNotAPlasmaRifle(); + + virtual void attack() const; + +private: +}; #endif diff --git a/cpp04/ex01/PowerFist.hpp b/cpp04/ex01/PowerFist.hpp index 100933a..fa347c8 100644 --- a/cpp04/ex01/PowerFist.hpp +++ b/cpp04/ex01/PowerFist.hpp @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 13:14:42 by charles #+# #+# */ -/* Updated: 2020/11/12 13:40:00 by cacharle ### ########.fr */ +/* Updated: 2020/12/11 10:41:32 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,7 +22,7 @@ public: PowerFist(); PowerFist(PowerFist const& other); PowerFist& operator=(PowerFist const& other); - ~PowerFist(); + virtual ~PowerFist(); virtual void attack() const; diff --git a/cpp04/ex01/RadScorpion.cpp b/cpp04/ex01/RadScorpion.cpp index 7e2ea84..a5fcb27 100644 --- a/cpp04/ex01/RadScorpion.cpp +++ b/cpp04/ex01/RadScorpion.cpp @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 13:36:11 by charles #+# #+# */ -/* Updated: 2020/11/12 13:55:44 by cacharle ### ########.fr */ +/* Updated: 2020/12/11 10:54:28 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,3 +32,26 @@ RadScorpion::~RadScorpion() { std::cout << "* SPROTCH *" << std::endl; } + +/*****************************************************************************/ + +NotSoRadScorpion::NotSoRadScorpion() : Enemy(80, "NotSoRadScorpion") +{ + std::cout << "* not so click click click *" << std::endl; +} + +NotSoRadScorpion::NotSoRadScorpion(NotSoRadScorpion const& other) : Enemy(other) +{ + std::cout << "* not so click click click *" << std::endl; +} + +NotSoRadScorpion& NotSoRadScorpion::operator=(NotSoRadScorpion const& other) +{ + Enemy::operator=(other); + return *this; +} + +NotSoRadScorpion::~NotSoRadScorpion() +{ + std::cout << "* SPROTCH (fuck this correction pdf) *" << std::endl; +} diff --git a/cpp04/ex01/RadScorpion.hpp b/cpp04/ex01/RadScorpion.hpp index 70bac44..252fcc0 100644 --- a/cpp04/ex01/RadScorpion.hpp +++ b/cpp04/ex01/RadScorpion.hpp @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 13:35:04 by charles #+# #+# */ -/* Updated: 2020/11/13 11:41:55 by cacharle ### ########.fr */ +/* Updated: 2020/12/11 11:01:22 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,4 +27,15 @@ public: private: }; +class NotSoRadScorpion : public Enemy +{ +public: + NotSoRadScorpion(); + NotSoRadScorpion(NotSoRadScorpion const& other); + NotSoRadScorpion& operator=(NotSoRadScorpion const& other); + virtual ~NotSoRadScorpion(); + +private: +}; + #endif diff --git a/cpp04/ex01/main.cpp b/cpp04/ex01/main.cpp index 7b0729c..7b36816 100644 --- a/cpp04/ex01/main.cpp +++ b/cpp04/ex01/main.cpp @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 09:05:58 by charles #+# #+# */ -/* Updated: 2020/11/17 09:16:14 by cacharle ### ########.fr */ +/* Updated: 2020/12/11 11:02:36 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -217,5 +217,33 @@ int main() c.attack(r); } + std::cout << std::endl; + + { + std::cout << "================ MORE DERIVED ====================" << std::endl; + Character c("YOP"); + Enemy* r = new RadScorpion(); + Enemy* s = new SuperMutant(); + Enemy* n = new NotSoRadScorpion(); + c.attack(r); + c.attack(s); + c.attack(n); + AWeapon *pr = new PlasmaRifle(); + AWeapon *pf = new PowerFist(); + AWeapon *npr = new ThisIsNotAPlasmaRifle(); + c.equip(pr); + c.attack(n); + c.equip(pf); + c.attack(s); + c.equip(npr); + c.attack(r); + delete npr; + delete pf; + delete pr; + delete n; + delete s; + delete r; + } + return 0; } |
