aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-11-12 15:46:07 +0100
committerCharles Cabergs <me@cacharle.xyz>2020-11-12 15:46:07 +0100
commitb8e39b947890e74d82530e25ad9d02668aae1f0c (patch)
treef59acfdecb0711137c200a4c5acb854e351f9cf9
parent96dcf214a8c40529b251ea31ef037868583dd1da (diff)
downloadpiscine_cpp-b8e39b947890e74d82530e25ad9d02668aae1f0c.tar.gz
piscine_cpp-b8e39b947890e74d82530e25ad9d02668aae1f0c.tar.bz2
piscine_cpp-b8e39b947890e74d82530e25ad9d02668aae1f0c.zip
Reformating cpp04 classes
-rw-r--r--cpp04/ex00/Peon.cpp15
-rw-r--r--cpp04/ex00/Peon.hpp6
-rw-r--r--cpp04/ex00/Sorcerer.cpp38
-rw-r--r--cpp04/ex00/Sorcerer.hpp10
-rw-r--r--cpp04/ex00/Victim.cpp28
-rw-r--r--cpp04/ex00/Victim.hpp8
-rw-r--r--cpp04/ex00/main.cpp53
-rw-r--r--cpp04/ex01/AWeapon.cpp46
-rw-r--r--cpp04/ex01/AWeapon.hpp13
-rw-r--r--cpp04/ex01/Character.cpp40
-rw-r--r--cpp04/ex01/Character.hpp8
-rw-r--r--cpp04/ex01/Enemy.cpp39
-rw-r--r--cpp04/ex01/Enemy.hpp11
-rw-r--r--cpp04/ex01/PlasmaRifle.cpp19
-rw-r--r--cpp04/ex01/PlasmaRifle.hpp4
-rw-r--r--cpp04/ex01/PowerFist.cpp19
-rw-r--r--cpp04/ex01/PowerFist.hpp4
-rw-r--r--cpp04/ex01/RadScorpion.cpp11
-rw-r--r--cpp04/ex01/RadScorpion.hpp4
-rw-r--r--cpp04/ex01/SuperMutant.cpp11
-rw-r--r--cpp04/ex01/SuperMutant.hpp4
-rw-r--r--cpp04/ex01/main.cpp52
-rw-r--r--cpp04/ex02/AssaultTerminator.cpp10
-rw-r--r--cpp04/ex02/AssaultTerminator.hpp4
-rw-r--r--cpp04/ex02/Squad.cpp24
-rw-r--r--cpp04/ex02/Squad.hpp5
-rw-r--r--cpp04/ex02/TacticalMarine.cpp10
-rw-r--r--cpp04/ex02/TacticalMarine.hpp4
-rw-r--r--cpp04/ex03/AMateria.cpp28
-rw-r--r--cpp04/ex03/AMateria.hpp6
-rw-r--r--cpp04/ex03/Character.cpp24
-rw-r--r--cpp04/ex03/Character.hpp8
-rw-r--r--cpp04/ex03/Cure.cpp23
-rw-r--r--cpp04/ex03/Cure.hpp4
-rw-r--r--cpp04/ex03/ICharacter.hpp6
-rw-r--r--cpp04/ex03/Ice.cpp23
-rw-r--r--cpp04/ex03/Ice.hpp4
-rw-r--r--cpp04/ex03/MateriaSource.cpp20
-rw-r--r--cpp04/ex03/MateriaSource.hpp5
39 files changed, 280 insertions, 371 deletions
diff --git a/cpp04/ex00/Peon.cpp b/cpp04/ex00/Peon.cpp
index df55b4f..8388dc9 100644
--- a/cpp04/ex00/Peon.cpp
+++ b/cpp04/ex00/Peon.cpp
@@ -6,27 +6,24 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/13 20:53:16 by charles #+# #+# */
-/* Updated: 2020/04/13 21:00:23 by charles ### ########.fr */
+/* Updated: 2020/11/12 13:01:42 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Peon.hpp"
-Peon::Peon(std::string name):
- Victim(name)
+Peon::Peon(std::string const& name) : Victim(name)
{
std::cout << "Zog zog." << std::endl;
}
-void Peon::operator=(Peon const& other)
+Peon& Peon::operator=(Peon const& other)
{
- m_name = other.m_name;
+ Victim::operator=(other);
+ return *this;
}
-Peon::Peon(Peon const& other)
- : Victim(other)
-{
-}
+Peon::Peon(Peon const& other) : Victim(other) {}
Peon::~Peon()
{
diff --git a/cpp04/ex00/Peon.hpp b/cpp04/ex00/Peon.hpp
index 2d57a05..0f50207 100644
--- a/cpp04/ex00/Peon.hpp
+++ b/cpp04/ex00/Peon.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/13 20:50:54 by charles #+# #+# */
-/* Updated: 2020/04/13 20:57:37 by charles ### ########.fr */
+/* Updated: 2020/11/12 13:00:49 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,8 +20,8 @@
class Peon : public Victim
{
public:
- Peon(std::string name);
- void operator=(Peon const& other);
+ Peon(std::string const& name);
+ Peon& operator=(Peon const& other);
Peon(Peon const& other);
~Peon();
diff --git a/cpp04/ex00/Sorcerer.cpp b/cpp04/ex00/Sorcerer.cpp
index c6910ce..c3d0999 100644
--- a/cpp04/ex00/Sorcerer.cpp
+++ b/cpp04/ex00/Sorcerer.cpp
@@ -6,54 +6,40 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/13 20:29:19 by charles #+# #+# */
-/* Updated: 2020/04/13 20:49:48 by charles ### ########.fr */
+/* Updated: 2020/11/12 12:55:36 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Sorcerer.hpp"
-Sorcerer::Sorcerer(std::string name, std::string title):
+Sorcerer::Sorcerer(std::string const& name, std::string const& title) :
m_name(name),
m_title(title)
{
std::cout << name << ", " << title << ", is born!" << std::endl;
}
-void Sorcerer::operator=(Sorcerer const& other)
+Sorcerer& Sorcerer::operator=(Sorcerer const& other)
{
- m_name = other.m_name;
+ m_name = other.m_name;
m_title = other.m_title;
+ return *this;
}
-Sorcerer::Sorcerer(Sorcerer const& other)
-{
- *this = other;
-}
+Sorcerer::Sorcerer(Sorcerer const& other) { *this = other; }
Sorcerer::~Sorcerer()
{
std::cout << m_name << ", " << m_title
- << ", is dead. Consequences will never be the same!" << std::endl;
-}
-
-std::string const& Sorcerer::getName() const
-{
- return m_name;
-}
-
-std::string const& Sorcerer::getTitle() const
-{
- return m_title;
+ << ", is dead. Consequences will never be the same!"
+ << std::endl;
}
-void Sorcerer::polymorph(Victim const& v) const
-{
- v.getPolymorphed();
-}
+std::string const& Sorcerer::getName() const { return m_name; }
+std::string const& Sorcerer::getTitle() const { return m_title; }
+void Sorcerer::polymorph(Victim const& v) const { v.getPolymorphed(); }
-Sorcerer::Sorcerer()
-{
-}
+Sorcerer::Sorcerer() {}
std::ostream& operator<<(std::ostream& out, Sorcerer const& s)
{
diff --git a/cpp04/ex00/Sorcerer.hpp b/cpp04/ex00/Sorcerer.hpp
index ed261ae..cf7676b 100644
--- a/cpp04/ex00/Sorcerer.hpp
+++ b/cpp04/ex00/Sorcerer.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/13 20:27:26 by charles #+# #+# */
-/* Updated: 2020/04/13 20:58:46 by charles ### ########.fr */
+/* Updated: 2020/11/12 12:51:45 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,13 +20,13 @@
class Sorcerer
{
public:
- Sorcerer(std::string name, std::string title);
- void operator=(Sorcerer const& other);
+ Sorcerer(std::string const& name, std::string const& title);
+ Sorcerer& operator=(Sorcerer const& other);
Sorcerer(Sorcerer const& other);
~Sorcerer();
- std::string const& getName() const;
- std::string const& getTitle() const;
+ std::string const& getName() const;
+ std::string const& getTitle() const;
void polymorph(Victim const& v) const;
private:
diff --git a/cpp04/ex00/Victim.cpp b/cpp04/ex00/Victim.cpp
index 2f2f6ad..97db6ff 100644
--- a/cpp04/ex00/Victim.cpp
+++ b/cpp04/ex00/Victim.cpp
@@ -6,46 +6,40 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/13 20:42:22 by charles #+# #+# */
-/* Updated: 2020/04/13 20:59:51 by charles ### ########.fr */
+/* Updated: 2020/11/12 12:59:36 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Victim.hpp"
-Victim::Victim(std::string name) :
- m_name(name)
+Victim::Victim(std::string const& name) : m_name(name)
{
- std::cout << "Some random victim called " << name << " just appeared!" << std::endl;
+ std::cout << "Some random victim called " << name
+ << " just appeared!" << std::endl;
}
-void Victim::operator=(Victim const& other)
+Victim& Victim::operator=(Victim const& other)
{
m_name = other.m_name;
+ return *this;
}
-Victim::Victim(Victim const& other)
-{
- *this = other;
-}
+Victim::Victim(Victim const& other) { *this = other; }
Victim::~Victim()
{
- std::cout << "Victim " << m_name << " just died for no apparent reason!" << std::endl;
+ std::cout << "Victim " << m_name
+ << " just died for no apparent reason!" << std::endl;
}
-std::string const& Victim::getName() const
-{
- return m_name;
-}
+std::string const& Victim::getName() const { return m_name; }
void Victim::getPolymorphed() const
{
std::cout << m_name << " has been turned into a cute little sheep!" << std::endl;
}
-Victim::Victim()
-{
-}
+Victim::Victim() {}
std::ostream& operator<<(std::ostream& out, Victim const& v)
{
diff --git a/cpp04/ex00/Victim.hpp b/cpp04/ex00/Victim.hpp
index dafd8c6..bf2b467 100644
--- a/cpp04/ex00/Victim.hpp
+++ b/cpp04/ex00/Victim.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/13 20:40:50 by charles #+# #+# */
-/* Updated: 2020/04/13 20:59:08 by charles ### ########.fr */
+/* Updated: 2020/11/12 12:57:01 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -19,12 +19,12 @@
class Victim
{
public:
- Victim(std::string name);
- void operator=(Victim const& other);
+ Victim(std::string const& name);
+ Victim& operator=(Victim const& other);
Victim(Victim const& other);
~Victim();
- std::string const& getName() const;
+ std::string const& getName() const;
virtual void getPolymorphed() const;
protected:
diff --git a/cpp04/ex00/main.cpp b/cpp04/ex00/main.cpp
index 9c17e99..8bf96bf 100644
--- a/cpp04/ex00/main.cpp
+++ b/cpp04/ex00/main.cpp
@@ -6,25 +6,64 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/13 20:47:34 by charles #+# #+# */
-/* Updated: 2020/04/13 20:57:19 by charles ### ########.fr */
+/* Updated: 2020/11/12 13:11:26 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
+#include <iostream>
#include "Sorcerer.hpp"
#include "Victim.hpp"
#include "Peon.hpp"
int main()
{
- Sorcerer robert("Robert", "the Magnificent");
+ {
+ std::cout << "==================== SUBJECT MAIN =====================" << std::endl;
+ Sorcerer robert("Robert", "the Magnificent");
+ Victim jim("Jimmy");
+ Peon joe("Joe");
+ std::cout << robert << jim << joe;
+ robert.polymorph(jim);
+ robert.polymorph(joe);
+ }
- Victim jim("Jimmy");
- Peon joe("Joe");
+ std::cout << std::endl;
- std::cout << robert << jim << joe;
+ {
+ std::cout << "==================== SORCERER =====================" << std::endl;
+ Sorcerer s("DidierLeSorcier", "The cunt");
+ Sorcerer s_copied(s);
+ Sorcerer s_assigned("foo", "yep clock");
+ s_assigned = s;
+ std::cout << "Copied: " << s_copied;
+ std::cout << "Assigned: " << s_assigned;
+ }
- robert.polymorph(jim);
- robert.polymorph(joe);
+ std::cout << std::endl;
+
+ {
+ std::cout << "==================== VICTIM =====================" << std::endl;
+ Victim v("Victoire");
+ Victim v_copied(v);
+ Victim v_assigned("bar");
+ v_assigned = v;
+ std::cout << "Copied: " << v_copied;
+ std::cout << "Assigned: " << v_assigned;
+ v.getPolymorphed();
+ }
+
+ std::cout << std::endl;
+
+ {
+ std::cout << "==================== PEON =====================" << std::endl;
+ Peon p("Victoire");
+ Peon p_copied(p);
+ Peon p_assigned("baz");
+ p_assigned = p;
+ std::cout << "Copied: " << p_copied;
+ std::cout << "Assigned: " << p_assigned;
+ p.getPolymorphed();
+ }
return 0;
}
diff --git a/cpp04/ex01/AWeapon.cpp b/cpp04/ex01/AWeapon.cpp
index 9c53839..5d43cd5 100644
--- a/cpp04/ex01/AWeapon.cpp
+++ b/cpp04/ex01/AWeapon.cpp
@@ -6,48 +6,30 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 12:16:04 by charles #+# #+# */
-/* Updated: 2020/04/14 13:18:07 by charles ### ########.fr */
+/* Updated: 2020/11/12 13:32:58 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "AWeapon.hpp"
-AWeapon::AWeapon(AWeapon const& other)
-{
- *this = other;
-}
-
-void AWeapon::operator=(AWeapon const& other)
-{
- m_name = other.m_name;
- m_apcost = other.m_apcost;
- m_damage = other.m_damage;
-}
-
-AWeapon::~AWeapon()
-{
-}
-
AWeapon::AWeapon(std::string const& name, int apcost, int damage)
: m_name(name), m_apcost(apcost), m_damage(damage)
-{
-}
+{}
-std::string const& AWeapon::getName() const
-{
- return m_name;
-}
+AWeapon::AWeapon(AWeapon const& other) { *this = other; }
-int AWeapon::getAPCost() const
+AWeapon& AWeapon::operator=(AWeapon const& other)
{
- return m_apcost;
+ m_name = other.m_name;
+ m_apcost = other.m_apcost;
+ m_damage = other.m_damage;
+ return *this;
}
-int AWeapon::getDamage() const
-{
- return m_damage;
-}
+AWeapon::~AWeapon() {}
-AWeapon::AWeapon()
-{
-}
+std::string const& AWeapon::getName() const { return m_name; }
+int AWeapon::getAPCost() const { return m_apcost; }
+int AWeapon::getDamage() const { return m_damage; }
+
+AWeapon::AWeapon() {}
diff --git a/cpp04/ex01/AWeapon.hpp b/cpp04/ex01/AWeapon.hpp
index 468f966..0296cd5 100644
--- a/cpp04/ex01/AWeapon.hpp
+++ b/cpp04/ex01/AWeapon.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 11:22:06 by charles #+# #+# */
-/* Updated: 2020/04/14 14:33:07 by charles ### ########.fr */
+/* Updated: 2020/11/12 13:34:13 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -19,7 +19,7 @@ class AWeapon
{
public:
AWeapon(AWeapon const& other);
- void operator=(AWeapon const& other);
+ AWeapon& operator=(AWeapon const& other);
virtual ~AWeapon();
AWeapon(std::string const& name, int apcost, int damage);
@@ -29,10 +29,13 @@ public:
virtual void attack() const = 0;
protected:
- AWeapon();
std::string m_name;
- int m_apcost;
- int m_damage;
+ int m_apcost;
+ int m_damage;
+
+private:
+ AWeapon();
+
};
#endif
diff --git a/cpp04/ex01/Character.cpp b/cpp04/ex01/Character.cpp
index e06be50..5f865c7 100644
--- a/cpp04/ex01/Character.cpp
+++ b/cpp04/ex01/Character.cpp
@@ -6,29 +6,26 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 13:44:35 by charles #+# #+# */
-/* Updated: 2020/04/14 14:13:39 by charles ### ########.fr */
+/* Updated: 2020/11/12 14:28:26 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Character.hpp"
-Character::Character(Character const& other)
-{
- *this = other;
-}
+Character::Character(std::string const& name) :
+ m_name(name), m_ap(40), m_weapon(NULL) {}
-void Character::operator=(Character const& other)
-{
- m_name = other.m_name;
-}
+Character::Character(Character const& other) { *this = other; }
-Character::~Character()
+Character& Character::operator=(Character const& other)
{
+ m_name = other.m_name;
+ m_ap = other.m_ap;
+ m_weapon = other.m_weapon;
+ return *this;
}
-Character::Character(std::string const& name) : m_name(name), m_ap(40), m_weapon(NULL)
-{
-}
+Character::~Character() {}
void Character::recoverAP()
{
@@ -54,20 +51,9 @@ void Character::attack(Enemy *enemy)
m_ap -= m_weapon->getAPCost();
}
-std::string const& Character::getName() const
-{
- return m_name;
-}
-
-int Character::getAP() const
-{
- return m_ap;
-}
-
-AWeapon* Character::getWeapon() const
-{
- return m_weapon;
-}
+std::string const& Character::getName() const { return m_name; }
+int Character::getAP() const { return m_ap; }
+AWeapon* Character::getWeapon() const { return m_weapon; }
std::ostream& operator<<(std::ostream& out, Character const& c)
{
diff --git a/cpp04/ex01/Character.hpp b/cpp04/ex01/Character.hpp
index 04da9fc..817fd53 100644
--- a/cpp04/ex01/Character.hpp
+++ b/cpp04/ex01/Character.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 13:42:25 by charles #+# #+# */
-/* Updated: 2020/04/14 14:09:51 by charles ### ########.fr */
+/* Updated: 2020/11/12 13:56:59 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -22,7 +22,7 @@ class Character
{
public:
Character(Character const& other);
- void operator=(Character const& other);
+ Character& operator=(Character const& other);
~Character();
Character(std::string const& name);
@@ -37,8 +37,8 @@ private:
Character();
std::string m_name;
- int m_ap;
- AWeapon *m_weapon;
+ int m_ap;
+ AWeapon* m_weapon;
};
std::ostream& operator<<(std::ostream& out, Character const& c);
diff --git a/cpp04/ex01/Enemy.cpp b/cpp04/ex01/Enemy.cpp
index 321ca68..c04f01b 100644
--- a/cpp04/ex01/Enemy.cpp
+++ b/cpp04/ex01/Enemy.cpp
@@ -6,49 +6,36 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 13:23:47 by charles #+# #+# */
-/* Updated: 2020/04/14 14:11:19 by charles ### ########.fr */
+/* Updated: 2020/11/12 13:50:10 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Enemy.hpp"
-Enemy::Enemy(Enemy const& other)
-{
- *this = other;
-}
+Enemy::Enemy(int hp, std::string const& type) : m_hp(hp), m_type(type) {}
-void Enemy::operator=(Enemy const& other)
-{
- m_hp = other.m_hp;
- m_type = other.m_type;
-}
+Enemy::Enemy(Enemy const& other) { *this = other; }
-Enemy::~Enemy()
+Enemy& Enemy::operator=(Enemy const& other)
{
+ m_hp = other.m_hp;
+ m_type = other.m_type;
+ return *this;
}
-Enemy::Enemy(int hp, std::string const& type)
- : m_hp(hp), m_type(type)
-{
-}
+Enemy::~Enemy() {}
-std::string const& Enemy::getType() const
-{
- return m_type;
-}
-int Enemy::getHP() const
-{
- return m_hp;
-}
+std::string const& Enemy::getType() const { return m_type; }
+int Enemy::getHP() const { return m_hp; }
void Enemy::takeDamage(int amount)
{
if (amount < 0)
return;
m_hp -= amount;
+ if (m_hp < 0)
+ m_hp = 0;
}
-Enemy::Enemy()
-{
-}
+Enemy::Enemy() {}
diff --git a/cpp04/ex01/Enemy.hpp b/cpp04/ex01/Enemy.hpp
index 582a61c..8b0dbf1 100644
--- a/cpp04/ex01/Enemy.hpp
+++ b/cpp04/ex01/Enemy.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 13:23:40 by charles #+# #+# */
-/* Updated: 2020/04/14 14:13:07 by charles ### ########.fr */
+/* Updated: 2020/11/12 13:55:07 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -19,7 +19,7 @@ class Enemy
{
public:
Enemy(Enemy const& other);
- void operator=(Enemy const& other);
+ Enemy& operator=(Enemy const& other);
virtual ~Enemy();
Enemy(int hp, std::string const& type);
@@ -30,10 +30,11 @@ public:
virtual void takeDamage(int amount);
protected:
- Enemy();
-
- int m_hp;
+ int m_hp;
std::string m_type;
+
+private:
+ Enemy();
};
#endif
diff --git a/cpp04/ex01/PlasmaRifle.cpp b/cpp04/ex01/PlasmaRifle.cpp
index 6629905..fc6bddd 100644
--- a/cpp04/ex01/PlasmaRifle.cpp
+++ b/cpp04/ex01/PlasmaRifle.cpp
@@ -6,30 +6,23 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 13:07:24 by charles #+# #+# */
-/* Updated: 2020/04/14 13:18:53 by charles ### ########.fr */
+/* Updated: 2020/11/12 13:35:36 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "PlasmaRifle.hpp"
-PlasmaRifle::PlasmaRifle()
- : AWeapon("Plasma Rifle", 5, 21)
-{
-}
+PlasmaRifle::PlasmaRifle() : AWeapon("Plasma Rifle", 5, 21) {}
-PlasmaRifle::PlasmaRifle(PlasmaRifle const& other)
-{
- *this = other;
-}
+PlasmaRifle::PlasmaRifle(PlasmaRifle const& other) : AWeapon(other) {}
-void PlasmaRifle::operator=(PlasmaRifle const& other)
+PlasmaRifle& PlasmaRifle::operator=(PlasmaRifle const& other)
{
AWeapon::operator=(other);
+ return *this;
}
-PlasmaRifle::~PlasmaRifle()
-{
-}
+PlasmaRifle::~PlasmaRifle() {}
void PlasmaRifle::attack() const
{
diff --git a/cpp04/ex01/PlasmaRifle.hpp b/cpp04/ex01/PlasmaRifle.hpp
index ef7caab..8ce7b0d 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/04/14 14:04:39 by charles ### ########.fr */
+/* Updated: 2020/11/12 13:36:55 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,7 +21,7 @@ class PlasmaRifle : public AWeapon
public:
PlasmaRifle();
PlasmaRifle(PlasmaRifle const& other);
- void operator=(PlasmaRifle const& other);
+ PlasmaRifle& operator=(PlasmaRifle const& other);
~PlasmaRifle();
virtual void attack() const;
diff --git a/cpp04/ex01/PowerFist.cpp b/cpp04/ex01/PowerFist.cpp
index d14deba..2ae0337 100644
--- a/cpp04/ex01/PowerFist.cpp
+++ b/cpp04/ex01/PowerFist.cpp
@@ -6,30 +6,23 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 13:15:42 by charles #+# #+# */
-/* Updated: 2020/04/14 14:09:51 by charles ### ########.fr */
+/* Updated: 2020/11/12 13:40:53 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "PowerFist.hpp"
-PowerFist::PowerFist()
- : AWeapon("Power Fist", 8, 50)
-{
-}
+PowerFist::PowerFist() : AWeapon("Power Fist", 8, 50) {}
-PowerFist::PowerFist(PowerFist const& other)
-{
- *this = other;
-}
+PowerFist::PowerFist(PowerFist const& other) : AWeapon(other) {}
-void PowerFist::operator=(PowerFist const& other)
+PowerFist& PowerFist::operator=(PowerFist const& other)
{
AWeapon::operator=(other);
+ return *this;
}
-PowerFist::~PowerFist()
-{
-}
+PowerFist::~PowerFist() {}
void PowerFist::attack() const
{
diff --git a/cpp04/ex01/PowerFist.hpp b/cpp04/ex01/PowerFist.hpp
index 2fbf212..100933a 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/04/14 14:04:27 by charles ### ########.fr */
+/* Updated: 2020/11/12 13:40:00 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,7 +21,7 @@ class PowerFist : public AWeapon
public:
PowerFist();
PowerFist(PowerFist const& other);
- void operator=(PowerFist const& other);
+ PowerFist& operator=(PowerFist const& other);
~PowerFist();
virtual void attack() const;
diff --git a/cpp04/ex01/RadScorpion.cpp b/cpp04/ex01/RadScorpion.cpp
index 8422fb7..7e2ea84 100644
--- a/cpp04/ex01/RadScorpion.cpp
+++ b/cpp04/ex01/RadScorpion.cpp
@@ -6,27 +6,26 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 13:36:11 by charles #+# #+# */
-/* Updated: 2020/04/14 13:37:54 by charles ### ########.fr */
+/* Updated: 2020/11/12 13:55:44 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "RadScorpion.hpp"
-RadScorpion::RadScorpion()
- : Enemy(80, "RadScorpion")
+RadScorpion::RadScorpion() : Enemy(80, "RadScorpion")
{
std::cout << "* click click click *" << std::endl;
}
-RadScorpion::RadScorpion(RadScorpion const& other)
+RadScorpion::RadScorpion(RadScorpion const& other) : Enemy(other)
{
- *this = other;
std::cout << "* click click click *" << std::endl;
}
-void RadScorpion::operator=(RadScorpion const& other)
+RadScorpion& RadScorpion::operator=(RadScorpion const& other)
{
Enemy::operator=(other);
+ return *this;
}
RadScorpion::~RadScorpion()
diff --git a/cpp04/ex01/RadScorpion.hpp b/cpp04/ex01/RadScorpion.hpp
index 71b98db..f07891e 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/04/14 13:37:58 by charles ### ########.fr */
+/* Updated: 2020/11/12 14:24:38 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,7 +21,7 @@ class RadScorpion : public Enemy
public:
RadScorpion();
RadScorpion(RadScorpion const& other);
- void operator=(RadScorpion const& other);
+ RadScorpion& operator=(RadScorpion const& other);
~RadScorpion();
private:
diff --git a/cpp04/ex01/SuperMutant.cpp b/cpp04/ex01/SuperMutant.cpp
index ba0a8a9..c9ce83c 100644
--- a/cpp04/ex01/SuperMutant.cpp
+++ b/cpp04/ex01/SuperMutant.cpp
@@ -6,27 +6,26 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 13:30:47 by charles #+# #+# */
-/* Updated: 2020/04/14 13:34:32 by charles ### ########.fr */
+/* Updated: 2020/11/12 13:54:19 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "SuperMutant.hpp"
-SuperMutant::SuperMutant()
- : Enemy(170, "Super Mutant")
+SuperMutant::SuperMutant() : Enemy(170, "Super Mutant")
{
std::cout << "Gaaah. Me want smash heads!" << std::endl;
}
-SuperMutant::SuperMutant(SuperMutant const& other)
+SuperMutant::SuperMutant(SuperMutant const& other) : Enemy(other)
{
std::cout << "Gaaah. Me want smash heads!" << std::endl;
- *this = other;
}
-void SuperMutant::operator=(SuperMutant const& other)
+SuperMutant& SuperMutant::operator=(SuperMutant const& other)
{
Enemy::operator=(other);
+ return *this;
}
SuperMutant::~SuperMutant()
diff --git a/cpp04/ex01/SuperMutant.hpp b/cpp04/ex01/SuperMutant.hpp
index 1a890cc..64198de 100644
--- a/cpp04/ex01/SuperMutant.hpp
+++ b/cpp04/ex01/SuperMutant.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 13:29:53 by charles #+# #+# */
-/* Updated: 2020/04/14 13:37:56 by charles ### ########.fr */
+/* Updated: 2020/11/12 13:50:54 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,7 +21,7 @@ class SuperMutant : public Enemy
public:
SuperMutant();
SuperMutant(SuperMutant const& other);
- void operator=(SuperMutant const& other);
+ SuperMutant& operator=(SuperMutant const& other);
~SuperMutant();
virtual void takeDamage(int amount);
diff --git a/cpp04/ex01/main.cpp b/cpp04/ex01/main.cpp
index 6798b57..ca5b35e 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/04/14 14:09:51 by charles ### ########.fr */
+/* Updated: 2020/11/12 14:36:49 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,27 +17,35 @@
int main()
{
- Character* me = new Character("me");
-
- std::cout << *me;
-
- Enemy* b = new RadScorpion();
-
- AWeapon* pr = new PlasmaRifle();
- AWeapon* pf = new PowerFist();
-
- me->equip(pr);
- std::cout << *me;
- me->equip(pf);
-
- me->attack(b);
- std::cout << *me;
- me->equip(pr);
- std::cout << *me;
- me->attack(b);
- std::cout << *me;
- me->attack(b);
- std::cout << *me;
+ {
+ std::cout << "================ SUBJECT MAIN =====================" << std::endl;
+ Character* me = new Character("me");
+ std::cout << *me;
+ Enemy* b = new RadScorpion();
+ AWeapon* pr = new PlasmaRifle();
+ AWeapon* pf = new PowerFist();
+ me->equip(pr);
+ std::cout << *me;
+ me->equip(pf);
+ me->attack(b);
+ std::cout << *me;
+ me->equip(pr);
+ std::cout << *me;
+ me->attack(b);
+ std::cout << *me;
+ me->attack(b);
+ std::cout << *me;
+ delete me;
+ ((RadScorpion*)b)->~RadScorpion();
+ delete pr;
+ delete pf;
+ }
+
+ std::cout << std::endl;
+
+ {
+
+ }
return 0;
}
diff --git a/cpp04/ex02/AssaultTerminator.cpp b/cpp04/ex02/AssaultTerminator.cpp
index 40518da..c00a00c 100644
--- a/cpp04/ex02/AssaultTerminator.cpp
+++ b/cpp04/ex02/AssaultTerminator.cpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 15:47:06 by charles #+# #+# */
-/* Updated: 2020/04/14 15:51:46 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:37:48 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,14 +17,12 @@ AssaultTerminator::AssaultTerminator()
std::cout << "* teleports from space *" << std::endl;
}
-AssaultTerminator::AssaultTerminator(AssaultTerminator const& other)
-{
- *this = other;
-}
+AssaultTerminator::AssaultTerminator(AssaultTerminator const& other) { *this = other; }
-void AssaultTerminator::operator=(AssaultTerminator const& other)
+AssaultTerminator& AssaultTerminator::operator=(AssaultTerminator const& other)
{
(void)other;
+ return *this;
}
AssaultTerminator::~AssaultTerminator()
diff --git a/cpp04/ex02/AssaultTerminator.hpp b/cpp04/ex02/AssaultTerminator.hpp
index e2d7acd..b2064f1 100644
--- a/cpp04/ex02/AssaultTerminator.hpp
+++ b/cpp04/ex02/AssaultTerminator.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 15:46:20 by charles #+# #+# */
-/* Updated: 2020/04/14 15:52:47 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:36:54 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,7 +21,7 @@ class AssaultTerminator : public ISpaceMarine
public:
AssaultTerminator();
AssaultTerminator(AssaultTerminator const& other);
- void operator=(AssaultTerminator const& other);
+ AssaultTerminator& operator=(AssaultTerminator const& other);
virtual ~AssaultTerminator();
virtual ISpaceMarine* clone() const;
diff --git a/cpp04/ex02/Squad.cpp b/cpp04/ex02/Squad.cpp
index 11c7862..d1d988f 100644
--- a/cpp04/ex02/Squad.cpp
+++ b/cpp04/ex02/Squad.cpp
@@ -6,39 +6,29 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 15:08:35 by charles #+# #+# */
-/* Updated: 2020/04/15 10:06:04 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:38:55 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Squad.hpp"
-Squad::Squad() : m_units(new ISpaceMarine*[0]), m_size(0)
-{
-}
+Squad::Squad() : m_units(new ISpaceMarine*[0]), m_size(0) {}
-Squad::Squad(Squad const& other)
-{
- *this = other;
-}
+Squad::Squad(Squad const& other) { *this = other; }
-void Squad::operator=(Squad const& other)
+Squad& Squad::operator=(Squad const& other)
{
destroyUnits();
m_size = other.m_size;
m_units = new ISpaceMarine*[m_size];
for (int i = 0; i < m_size; i++)
m_units[i] = other.m_units[i]->clone();
+ return *this;
}
-Squad::~Squad()
-{
- destroyUnits();
-}
+Squad::~Squad() { destroyUnits(); }
-int Squad::getCount() const
-{
- return m_size;
-}
+int Squad::getCount() const { return m_size; }
ISpaceMarine* Squad::getUnit(int n) const
{
diff --git a/cpp04/ex02/Squad.hpp b/cpp04/ex02/Squad.hpp
index fda1148..9ea5268 100644
--- a/cpp04/ex02/Squad.hpp
+++ b/cpp04/ex02/Squad.hpp
@@ -6,13 +6,14 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 15:07:57 by charles #+# #+# */
-/* Updated: 2020/04/14 15:28:02 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:39:26 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SQUAD_HPP
# define SQUAD_HPP
+# include <cstdlib>
# include "ISquad.hpp"
# include "ISpaceMarine.hpp"
@@ -21,7 +22,7 @@ class Squad : public ISquad
public:
Squad();
Squad(Squad const& other);
- void operator=(Squad const& other);
+ Squad& operator=(Squad const& other);
virtual ~Squad();
virtual int getCount() const;
diff --git a/cpp04/ex02/TacticalMarine.cpp b/cpp04/ex02/TacticalMarine.cpp
index f2684ba..df771e8 100644
--- a/cpp04/ex02/TacticalMarine.cpp
+++ b/cpp04/ex02/TacticalMarine.cpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 15:31:43 by charles #+# #+# */
-/* Updated: 2020/04/14 15:45:55 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:37:41 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,14 +17,12 @@ TacticalMarine::TacticalMarine()
std::cout << "Tactical Marine ready for battle!" << std::endl;
}
-TacticalMarine::TacticalMarine(TacticalMarine const& other)
-{
- *this = other;
-}
+TacticalMarine::TacticalMarine(TacticalMarine const& other) { *this = other; }
-void TacticalMarine::operator=(TacticalMarine const& other)
+TacticalMarine& TacticalMarine::operator=(TacticalMarine const& other)
{
(void)other;
+ return *this;
}
TacticalMarine::~TacticalMarine()
diff --git a/cpp04/ex02/TacticalMarine.hpp b/cpp04/ex02/TacticalMarine.hpp
index 18dd0c9..43722d6 100644
--- a/cpp04/ex02/TacticalMarine.hpp
+++ b/cpp04/ex02/TacticalMarine.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 15:30:48 by charles #+# #+# */
-/* Updated: 2020/04/14 15:34:12 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:38:03 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,7 +21,7 @@ class TacticalMarine : public ISpaceMarine
public:
TacticalMarine();
TacticalMarine(TacticalMarine const& other);
- void operator=(TacticalMarine const& other);
+ TacticalMarine& operator=(TacticalMarine const& other);
virtual ~TacticalMarine();
virtual ISpaceMarine* clone() const;
diff --git a/cpp04/ex03/AMateria.cpp b/cpp04/ex03/AMateria.cpp
index 77e674b..1dc7ca9 100644
--- a/cpp04/ex03/AMateria.cpp
+++ b/cpp04/ex03/AMateria.cpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 16:26:57 by charles #+# #+# */
-/* Updated: 2020/04/14 16:35:09 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:40:23 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -18,35 +18,23 @@ AMateria::AMateria(AMateria const& other)
m_type = "";
}
-void AMateria::operator=(AMateria const& other)
+AMateria& AMateria::operator=(AMateria const& other)
{
_xp = other._xp;
+ return *this;
}
-AMateria::~AMateria()
-{
-}
+AMateria::~AMateria() {}
-AMateria::AMateria(std::string const& type)
- : m_type(type), _xp(0)
-{
-}
+AMateria::AMateria(std::string const& type) : m_type(type), _xp(0) {}
std::string const& AMateria::getType() const
{
return m_type;
}
-unsigned int AMateria::getXP() const
-{
- return _xp;
-}
+unsigned int AMateria::getXP() const { return _xp; }
-void AMateria::use(ICharacter& target)
-{
- _xp += 10;
-}
+void AMateria::use(ICharacter& target) { _xp += 10; }
-AMateria::AMateria()
-{
-}
+AMateria::AMateria() {}
diff --git a/cpp04/ex03/AMateria.hpp b/cpp04/ex03/AMateria.hpp
index 65d5cc5..7fef1c8 100644
--- a/cpp04/ex03/AMateria.hpp
+++ b/cpp04/ex03/AMateria.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 16:24:00 by charles #+# #+# */
-/* Updated: 2020/04/14 17:55:18 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:41:54 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,11 +16,13 @@
# include <string>
# include "ICharacter.hpp"
+class ICharacter;
+
class AMateria
{
public:
AMateria(AMateria const& other);
- void operator=(AMateria const& other);
+ AMateria& operator=(AMateria const& other);
virtual ~AMateria();
AMateria(std::string const& type);
diff --git a/cpp04/ex03/Character.cpp b/cpp04/ex03/Character.cpp
index 34aaa48..ee03e63 100644
--- a/cpp04/ex03/Character.cpp
+++ b/cpp04/ex03/Character.cpp
@@ -6,22 +6,17 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 16:45:54 by charles #+# #+# */
-/* Updated: 2020/04/14 17:59:57 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:43:14 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Character.hpp"
-Character::Character() : m_name(""), m_inventory_size(0)
-{
-}
+Character::Character() : m_name(""), m_inventory_size(0) {}
-Character::Character(Character const& other)
-{
- *this = other;
-}
+Character::Character(Character const& other) { *this = other; }
-void Character::operator=(Character const& other)
+Character& Character::operator=(Character const& other)
{
for (int i = 0; i < m_inventory_size; i++)
delete m_inventory[i];
@@ -29,6 +24,7 @@ void Character::operator=(Character const& other)
for (int i = 0; i < m_inventory_size; i++)
m_inventory[i] = other.m_inventory[i]->clone();
m_name = other.m_name;
+ return *this;
}
Character::~Character()
@@ -37,15 +33,9 @@ Character::~Character()
delete m_inventory[i];
}
-Character::Character(std::string const& name)
- : m_name(name), m_inventory_size(0)
-{
-}
+Character::Character(std::string const& name) : m_name(name), m_inventory_size(0) {}
-std::string const& Character::getName() const
-{
- return m_name;
-}
+std::string const& Character::getName() const { return m_name; }
void Character::equip(AMateria* m)
{
diff --git a/cpp04/ex03/Character.hpp b/cpp04/ex03/Character.hpp
index c6ffc7b..6526ba2 100644
--- a/cpp04/ex03/Character.hpp
+++ b/cpp04/ex03/Character.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 16:44:43 by charles #+# #+# */
-/* Updated: 2020/04/14 17:31:49 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:42:43 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -22,7 +22,7 @@ class Character : public ICharacter
public:
Character();
Character(Character const& other);
- void operator=(Character const& other);
+ Character& operator=(Character const& other);
virtual ~Character();
Character(std::string const& name);
@@ -32,8 +32,8 @@ public:
virtual void use(int idx, ICharacter& target);
private:
- AMateria* m_inventory[INVENTORY_MAX_SIZE];
- int m_inventory_size;
+ AMateria* m_inventory[INVENTORY_MAX_SIZE];
+ int m_inventory_size;
std::string m_name;
};
diff --git a/cpp04/ex03/Cure.cpp b/cpp04/ex03/Cure.cpp
index 1f3e0d5..e27ae26 100644
--- a/cpp04/ex03/Cure.cpp
+++ b/cpp04/ex03/Cure.cpp
@@ -6,34 +6,25 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 17:38:01 by charles #+# #+# */
-/* Updated: 2020/04/14 17:41:32 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:43:44 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Cure.hpp"
-Cure::Cure() : AMateria("cure")
-{
-}
+Cure::Cure() : AMateria("cure") {}
-Cure::Cure(Cure const& other)
-{
- *this = other;
-}
+Cure::Cure(Cure const& other) { *this = other; }
-void Cure::operator=(Cure const& other)
+Cure& Cure::operator=(Cure const& other)
{
AMateria::operator=(other);
+ return *this;
}
-Cure::~Cure()
-{
-}
+Cure::~Cure() {}
-AMateria* Cure::clone() const
-{
- return new Cure(*this);
-}
+AMateria* Cure::clone() const { return new Cure(*this); }
void Cure::use(ICharacter& target)
{
diff --git a/cpp04/ex03/Cure.hpp b/cpp04/ex03/Cure.hpp
index 4c7a6dd..ccc86d5 100644
--- a/cpp04/ex03/Cure.hpp
+++ b/cpp04/ex03/Cure.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 17:37:11 by charles #+# #+# */
-/* Updated: 2020/04/14 17:42:52 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:43:24 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,7 +21,7 @@ class Cure : public AMateria
public:
Cure();
Cure(Cure const& other);
- void operator=(Cure const& other);
+ Cure& operator=(Cure const& other);
~Cure();
virtual AMateria* clone() const;
diff --git a/cpp04/ex03/ICharacter.hpp b/cpp04/ex03/ICharacter.hpp
index ea56d47..bb84d7e 100644
--- a/cpp04/ex03/ICharacter.hpp
+++ b/cpp04/ex03/ICharacter.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 16:40:25 by charles #+# #+# */
-/* Updated: 2020/04/14 17:55:14 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:42:12 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,6 +16,8 @@
# include <string>
# include "AMateria.hpp"
+class IMateria;
+
class ICharacter
{
public:
@@ -28,7 +30,7 @@ public:
protected:
ICharacter();
ICharacter(ICharacter const& other);
- void operator=(ICharacter const& other);
+ ICharacter& operator=(ICharacter const& other);
};
#endif
diff --git a/cpp04/ex03/Ice.cpp b/cpp04/ex03/Ice.cpp
index 976cb84..c663104 100644
--- a/cpp04/ex03/Ice.cpp
+++ b/cpp04/ex03/Ice.cpp
@@ -6,34 +6,25 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 16:32:27 by charles #+# #+# */
-/* Updated: 2020/04/14 17:36:26 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:44:48 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Ice.hpp"
-Ice::Ice() : AMateria("ice")
-{
-}
+Ice::Ice() : AMateria("ice") {}
-Ice::Ice(Ice const& other)
-{
- *this = other;
-}
+Ice::Ice(Ice const& other) { *this = other; }
-void Ice::operator=(Ice const& other)
+Ice& Ice::operator=(Ice const& other)
{
AMateria::operator=(other);
+ return *this;
}
-Ice::~Ice()
-{
-}
+Ice::~Ice() {}
-AMateria* Ice::clone() const
-{
- return new Ice(*this);
-}
+AMateria* Ice::clone() const { return new Ice(*this); }
void Ice::use(ICharacter& target)
{
diff --git a/cpp04/ex03/Ice.hpp b/cpp04/ex03/Ice.hpp
index 55011c0..8b670f6 100644
--- a/cpp04/ex03/Ice.hpp
+++ b/cpp04/ex03/Ice.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 16:31:34 by charles #+# #+# */
-/* Updated: 2020/04/14 17:38:30 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:44:31 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,7 +21,7 @@ class Ice : public AMateria
public:
Ice();
Ice(Ice const& other);
- void operator=(Ice const& other);
+ Ice& operator=(Ice const& other);
~Ice();
virtual AMateria* clone() const;
diff --git a/cpp04/ex03/MateriaSource.cpp b/cpp04/ex03/MateriaSource.cpp
index f5aaf60..087af3e 100644
--- a/cpp04/ex03/MateriaSource.cpp
+++ b/cpp04/ex03/MateriaSource.cpp
@@ -6,35 +6,25 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 17:19:10 by charles #+# #+# */
-/* Updated: 2020/04/15 10:05:47 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:45:23 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "MateriaSource.hpp"
-MateriaSource::MateriaSource()
-{
-
-}
+MateriaSource::MateriaSource() {}
-MateriaSource::MateriaSource(MateriaSource const& other)
-{
- *this = other;
-}
+MateriaSource::MateriaSource(MateriaSource const& other) { *this = other; }
void MateriaSource::operator=(MateriaSource const& other)
{
-
+ return *this;
}
-MateriaSource::~MateriaSource()
-{
-
-}
+MateriaSource::~MateriaSource() {}
void MateriaSource::learnMateria(AMateria* materia)
{
-
}
AMateria* MateriaSource::createMateria(std::string const& type)
diff --git a/cpp04/ex03/MateriaSource.hpp b/cpp04/ex03/MateriaSource.hpp
index a8b4c0e..eb233eb 100644
--- a/cpp04/ex03/MateriaSource.hpp
+++ b/cpp04/ex03/MateriaSource.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 17:17:40 by charles #+# #+# */
-/* Updated: 2020/04/14 17:33:50 by charles ### ########.fr */
+/* Updated: 2020/11/12 15:45:28 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,12 +16,13 @@
# include "IMateriaSource.hpp"
# define LEARNED_MAX_SIZE 4
+
class MateriaSource : public IMateriaSource
{
public:
MateriaSource();
MateriaSource(MateriaSource const& other);
- void operator=(MateriaSource const& other);
+ MateriaSource& operator=(MateriaSource const& other);
virtual ~MateriaSource();
virtual void learnMateria(AMateria* materia);