aboutsummaryrefslogtreecommitdiff
path: root/cpp04
diff options
context:
space:
mode:
Diffstat (limited to 'cpp04')
-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