Add abstract class AMateria and 2 child classes
authorLukas Jiriste <ljiriste@student.42prague.com>
Fri, 25 Oct 2024 13:06:02 +0000 (15:06 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Fri, 25 Oct 2024 13:06:02 +0000 (15:06 +0200)
ex03/AMateria.cpp [new file with mode: 0644]
ex03/AMateria.h [new file with mode: 0644]
ex03/Cure.cpp [new file with mode: 0644]
ex03/Cure.h [new file with mode: 0644]
ex03/Ice.cpp [new file with mode: 0644]
ex03/Ice.h [new file with mode: 0644]

diff --git a/ex03/AMateria.cpp b/ex03/AMateria.cpp
new file mode 100644 (file)
index 0000000..831d4c3
--- /dev/null
@@ -0,0 +1,35 @@
+#include "AMateria.h"
+#include "ICharacter.h"
+#include <string>
+
+AMateria::AMateria()
+{
+}
+
+AMateria::AMateria(const AMateria &other)
+       : m_type(other.m_type)
+{
+}
+
+AMateria::~AMateria()
+{
+}
+
+AMateria       &AMateria::operator=(const AMateria &other)
+{
+}
+
+AMateria::AMateria(const std::string &type)
+       : m_type(type)
+{
+}
+
+const std::string      &getType() const
+{
+       return (m_type);
+}
+
+void   use(ICharacter &target);
+{
+       std::cout << "* AMATERIA AFFECTS " << target.getName() << " *\n";
+}
diff --git a/ex03/AMateria.h b/ex03/AMateria.h
new file mode 100644 (file)
index 0000000..b4c8073
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef AMATERIA_H
+# define AMATERIA_H
+
+# include "ICharacter.h"
+# include <string>
+
+class AMateria
+{
+       private:
+               AMateria();
+               AMateria        &operator=(const AMateria &other);
+
+               const std::string       m_type;
+
+       public:
+               AMateria(const AMateria &other);
+               AMateria(const std::string &type);
+               virtual ~AMateria();
+
+               const std::string       &getType() const;
+
+               virtual AMateria        *clone() const = 0;
+               virtual void            use(ICharacter &target);
+};
+
+#endif // AMATERIA_H
diff --git a/ex03/Cure.cpp b/ex03/Cure.cpp
new file mode 100644 (file)
index 0000000..56eaff2
--- /dev/null
@@ -0,0 +1,30 @@
+#include "Cure.h"
+#include <iostream>
+
+Cure::Cure()
+       : AMateria("cure")
+{
+}
+
+Cure::Cure(const Cure &other)
+       : AMateria(other)
+{
+}
+
+Cure::~Cure()
+{
+}
+
+Cure   &Cure::operator=(const Cure &other)
+{
+}
+
+AMateria       *clone() const
+{
+       return (new Ice(*this));
+}
+
+void   use(ICharacter& target)
+{
+       std::cout << "* heals " << target.getName << "'s wounds *\n";
+}
diff --git a/ex03/Cure.h b/ex03/Cure.h
new file mode 100644 (file)
index 0000000..2b9ee9d
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef CURE_H
+# define CURE_H
+
+class Cure : public AMateria
+{
+       private:
+               Cure    &operator=(const Cure &other);
+
+       public:
+               Cure();
+               Cure(const Cure &other);
+               ~Cure();
+};
+
+#endif // CURE_H
diff --git a/ex03/Ice.cpp b/ex03/Ice.cpp
new file mode 100644 (file)
index 0000000..2e8a357
--- /dev/null
@@ -0,0 +1,30 @@
+#include "Ice.h"
+#include <iostream>
+
+Ice::Ice()
+       : AMateria("ice")
+{
+}
+
+Ice::Ice(const Ice &other)
+       : AMateria(other);
+{
+}
+
+Ice::~Ice()
+{
+}
+
+Ice    &Ice::operator=(const Ice &other)
+{
+}
+
+AMateria       *clone() const
+{
+       return (new Ice(*this));
+}
+
+void   use(ICharacter& target)
+{
+       std::cout << "* shoots an ice bolt at " << target.getName << " *\n";
+}
diff --git a/ex03/Ice.h b/ex03/Ice.h
new file mode 100644 (file)
index 0000000..c69a36e
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef ICE_H
+# define ICE_H
+
+class Ice : public AMateria
+{
+       private:
+               Ice     &operator=(const Ice &other);
+
+       public:
+               Ice();
+               Ice(const Ice &other);
+               ~Ice();
+};
+
+#endif // ICE_H