aboutsummaryrefslogtreecommitdiff
path: root/cpp04/ex01
diff options
context:
space:
mode:
Diffstat (limited to 'cpp04/ex01')
-rw-r--r--cpp04/ex01/PlasmaRifle.cpp21
-rw-r--r--cpp04/ex01/PlasmaRifle.hpp16
-rw-r--r--cpp04/ex01/PowerFist.hpp4
-rw-r--r--cpp04/ex01/RadScorpion.cpp25
-rw-r--r--cpp04/ex01/RadScorpion.hpp13
-rw-r--r--cpp04/ex01/main.cpp30
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;
}