├── .gitignore ├── README.md ├── cpp_module_01 ├── Dummy.cpp ├── Fwoosh.cpp ├── Dummy.hpp ├── Fwoosh.hpp ├── ATarget.hpp ├── ATarget.cpp ├── ASpell.hpp ├── ASpell.cpp ├── Warlock.hpp ├── main.cc └── Warlock.cpp ├── cpp_module_02 ├── Dummy.cpp ├── Fwoosh.cpp ├── BrickWall.cpp ├── Fireball.cpp ├── Polymorph.cpp ├── Dummy.hpp ├── Fwoosh.hpp ├── Fireball.hpp ├── Polymorph.hpp ├── BrickWall.hpp ├── TargetGenerator.hpp ├── SpellBook.hpp ├── ATarget.hpp ├── ATarget.cpp ├── ASpell.hpp ├── ASpell.cpp ├── Warlock.hpp ├── Warlock.cpp ├── SpellBook.cpp ├── TargetGenerator.cpp └── main.cc └── cpp_module_00 ├── main.cc ├── Warlock.hpp └── Warlock.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | *.o 3 | *.tmp 4 | exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Exam Rank 05 2 | 3 | It's C++. Copy/Paste... -------------------------------------------------------------------------------- /cpp_module_01/Dummy.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Dummy.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:16:30 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:41:43 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "Dummy.hpp" 14 | 15 | Dummy::Dummy(): 16 | ATarget("Dummy Practice") {} 17 | 18 | Dummy::~Dummy() {} 19 | 20 | ATarget *Dummy::clone(void) const { 21 | return (new Dummy(*this)); 22 | } 23 | -------------------------------------------------------------------------------- /cpp_module_02/Dummy.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Dummy.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:16:30 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:40:09 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "Dummy.hpp" 14 | 15 | Dummy::Dummy(): 16 | ATarget("Dummy Practice") {} 17 | 18 | Dummy::~Dummy() {} 19 | 20 | ATarget *Dummy::clone(void) const { 21 | return (new Dummy(*this)); 22 | } 23 | -------------------------------------------------------------------------------- /cpp_module_01/Fwoosh.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Fwoosh.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:24:08 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:41:40 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "Fwoosh.hpp" 14 | 15 | Fwoosh::Fwoosh(): 16 | ASpell("Fwoosh", "fwooshed") {} 17 | 18 | Fwoosh::~Fwoosh() {} 19 | 20 | ASpell *Fwoosh::clone(void) const { 21 | return (new Fwoosh(*this)); 22 | } 23 | -------------------------------------------------------------------------------- /cpp_module_02/Fwoosh.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Fwoosh.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:24:08 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:39:56 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "Fwoosh.hpp" 14 | 15 | Fwoosh::Fwoosh(): 16 | ASpell("Fwoosh", "fwooshed") {} 17 | 18 | Fwoosh::~Fwoosh() {} 19 | 20 | ASpell *Fwoosh::clone(void) const { 21 | return (new Fwoosh(*this)); 22 | } 23 | -------------------------------------------------------------------------------- /cpp_module_02/BrickWall.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* BrickWall.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/02/04 12:59:17 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:40:08 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "BrickWall.hpp" 14 | 15 | BrickWall::BrickWall(): 16 | ATarget("BrickWall Practice") {} 17 | 18 | BrickWall::~BrickWall() {} 19 | 20 | ATarget *BrickWall::clone(void) const { 21 | return (new BrickWall(*this)); 22 | } 23 | -------------------------------------------------------------------------------- /cpp_module_02/Fireball.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Fireball.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/02/04 12:49:03 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:40:00 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "Fireball.hpp" 14 | 15 | Fireball::Fireball(): 16 | ASpell("Fireball", "burnt to a crisp") {} 17 | 18 | Fireball::~Fireball() {} 19 | 20 | ASpell *Fireball::clone(void) const { 21 | return (new Fireball(*this)); 22 | } 23 | -------------------------------------------------------------------------------- /cpp_module_02/Polymorph.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Polymorph.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/02/04 12:49:28 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:39:49 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "Polymorph.hpp" 14 | 15 | Polymorph::Polymorph(): 16 | ASpell("Polymorph", "turned to a sheep") {} 17 | 18 | Polymorph::~Polymorph() {} 19 | 20 | ASpell *Polymorph::clone(void) const { 21 | return (new Polymorph(*this)); 22 | } 23 | -------------------------------------------------------------------------------- /cpp_module_01/Dummy.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Dummy.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:06:26 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/04 12:50:12 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef DUMMY_HPP 14 | # define DUMMY_HPP 15 | 16 | # include "ATarget.hpp" 17 | 18 | class Dummy: public ATarget 19 | { 20 | public: 21 | Dummy(); 22 | virtual ~Dummy(); 23 | 24 | virtual ATarget *clone(void) const; 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /cpp_module_01/Fwoosh.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Fwoosh.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:06:34 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/04 13:02:24 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef FWOOSH_HPP 14 | # define FWOOSH_HPP 15 | 16 | # include "ASpell.hpp" 17 | 18 | class Fwoosh: public ASpell 19 | { 20 | public: 21 | Fwoosh(); 22 | virtual ~Fwoosh(); 23 | 24 | virtual ASpell *clone(void) const; 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /cpp_module_02/Dummy.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Dummy.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:06:26 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/04 12:50:05 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef DUMMY_HPP 14 | # define DUMMY_HPP 15 | 16 | # include "ATarget.hpp" 17 | 18 | class Dummy: public ATarget 19 | { 20 | public: 21 | Dummy(); 22 | virtual ~Dummy(); 23 | 24 | virtual ATarget *clone(void) const; 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /cpp_module_02/Fwoosh.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Fwoosh.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:06:34 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/04 13:01:06 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef FWOOSH_HPP 14 | # define FWOOSH_HPP 15 | 16 | # include "ASpell.hpp" 17 | 18 | class Fwoosh: public ASpell 19 | { 20 | public: 21 | Fwoosh(); 22 | virtual ~Fwoosh(); 23 | 24 | virtual ASpell *clone(void) const; 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /cpp_module_02/Fireball.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Fireball.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/02/04 12:48:38 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/04 13:01:10 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef FIREBALL_HPP 14 | # define FIREBALL_HPP 15 | 16 | # include "ASpell.hpp" 17 | 18 | class Fireball: public ASpell 19 | { 20 | public: 21 | Fireball(); 22 | virtual ~Fireball(); 23 | 24 | virtual ASpell *clone(void) const; 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /cpp_module_02/Polymorph.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Polymorph.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/02/04 12:48:20 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/04 13:00:59 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef POLYMORPH_HPP 14 | # define POLYMORPH_HPP 15 | 16 | # include "ASpell.hpp" 17 | 18 | class Polymorph: public ASpell 19 | { 20 | public: 21 | Polymorph(); 22 | virtual ~Polymorph(); 23 | 24 | virtual ASpell *clone(void) const; 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /cpp_module_02/BrickWall.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* BrickWall.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/02/04 12:58:33 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/04 12:59:02 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef BRICKWALL_HPP 14 | # define BRICKWALL_HPP 15 | 16 | # include "ATarget.hpp" 17 | 18 | class BrickWall: public ATarget 19 | { 20 | public: 21 | BrickWall(); 22 | virtual ~BrickWall(); 23 | 24 | virtual ATarget *clone(void) const; 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /cpp_module_02/TargetGenerator.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* TargetGenerator.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/02/04 12:59:50 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:42:37 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef TARGETGENERATOR_HPP 14 | # define TARGETGENERATOR_HPP 15 | 16 | # include 17 | # include "ATarget.hpp" 18 | 19 | class TargetGenerator 20 | { 21 | private: 22 | std::vector types; 23 | public: 24 | TargetGenerator(); 25 | virtual ~TargetGenerator(); 26 | 27 | void learnTargetType(ATarget *type); 28 | void forgetTargetType(std::string const &name); 29 | ATarget *createTarget(std::string const &name); 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /cpp_module_02/SpellBook.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* SpellBook.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/02/04 12:51:10 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/11 11:56:59 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef SPELLBOOK_HPP 14 | # define SPELLBOOK_HPP 15 | 16 | # include 17 | # include "ASpell.hpp" 18 | 19 | class SpellBook 20 | { 21 | private: 22 | std::vector spells; 23 | 24 | SpellBook(SpellBook const &other); 25 | SpellBook &operator=(SpellBook const &other); 26 | public: 27 | SpellBook(); 28 | virtual ~SpellBook(); 29 | 30 | void learnSpell(ASpell *spell); 31 | void forgetSpell(std::string const &spellName); 32 | ASpell *generateSpell(std::string const &spellName); 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /cpp_module_00/main.cc: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.cc :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/17 00:33:40 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/04 13:11:01 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "Warlock.hpp" 14 | 15 | int main(void) 16 | { 17 | std::cout << "--- Constructors:\n"; 18 | // Warlock warlock; // Doesn't compile 19 | Warlock richard("Richard", "Master of the Universe"); 20 | // Warlock warlock(richard); // Doesn't compile 21 | // Warlock warlock = richard; // Doesn't compile 22 | 23 | std::cout << "--- Introduce:\n"; 24 | richard.introduce(); 25 | 26 | std::cout << "--- New Title:\n"; 27 | richard.setTitle("Master of the Earth"); 28 | richard.introduce(); 29 | 30 | std::cout << "--- Destructors:\n"; 31 | return (0); 32 | } 33 | -------------------------------------------------------------------------------- /cpp_module_01/ATarget.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ATarget.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:06:18 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/04 13:02:41 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef ATARGET_HPP 14 | # define ATARGET_HPP 15 | 16 | # include 17 | # include 18 | 19 | class ASpell; 20 | 21 | class ATarget 22 | { 23 | private: 24 | std::string type; 25 | public: 26 | ATarget(); 27 | ATarget(std::string const &type); 28 | ATarget(ATarget const &other); 29 | virtual ~ATarget(); 30 | 31 | ATarget &operator=(ATarget const &other); 32 | 33 | std::string const &getType(void) const; 34 | 35 | void getHitBySpell(ASpell const &spell) const; 36 | 37 | virtual ATarget *clone(void) const = 0; 38 | }; 39 | 40 | # include "ASpell.hpp" 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /cpp_module_02/ATarget.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ATarget.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:06:18 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/11 11:41:54 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef ATARGET_HPP 14 | # define ATARGET_HPP 15 | 16 | # include 17 | # include 18 | 19 | class ASpell; 20 | 21 | class ATarget 22 | { 23 | protected: 24 | std::string type; 25 | public: 26 | ATarget(); 27 | ATarget(std::string const &type); 28 | ATarget(ATarget const &other); 29 | virtual ~ATarget(); 30 | 31 | ATarget &operator=(ATarget const &other); 32 | 33 | std::string const &getType(void) const; 34 | 35 | void getHitBySpell(ASpell const &spell) const; 36 | 37 | virtual ATarget *clone(void) const = 0; 38 | }; 39 | 40 | # include "ASpell.hpp" 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /cpp_module_01/ATarget.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ATarget.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:26:40 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:41:49 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "ATarget.hpp" 14 | 15 | ATarget::ATarget(): 16 | type() {} 17 | 18 | ATarget::ATarget(std::string const &type): 19 | type(type) {} 20 | 21 | ATarget::ATarget(ATarget const &other): 22 | type(other.type) {} 23 | 24 | ATarget::~ATarget() {} 25 | 26 | ATarget &ATarget::operator=(ATarget const &other) { 27 | this->type = other.type; 28 | return (*this); 29 | } 30 | 31 | std::string const &ATarget::getType(void) const { 32 | return (this->type); 33 | } 34 | 35 | void ATarget::getHitBySpell(ASpell const &spell) const { 36 | std::cout << this->type << " has been " << spell.getEffects() << "!\n"; 37 | } 38 | -------------------------------------------------------------------------------- /cpp_module_02/ATarget.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ATarget.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:26:40 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:40:16 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "ATarget.hpp" 14 | 15 | ATarget::ATarget(): 16 | type() {} 17 | 18 | ATarget::ATarget(std::string const &type): 19 | type(type) {} 20 | 21 | ATarget::ATarget(ATarget const &other): 22 | type(other.type) {} 23 | 24 | ATarget::~ATarget() {} 25 | 26 | ATarget &ATarget::operator=(ATarget const &other) { 27 | this->type = other.type; 28 | return (*this); 29 | } 30 | 31 | std::string const &ATarget::getType(void) const { 32 | return (this->type); 33 | } 34 | 35 | void ATarget::getHitBySpell(ASpell const &spell) const { 36 | std::cout << this->type << " has been " << spell.getEffects() << "!\n"; 37 | } 38 | -------------------------------------------------------------------------------- /cpp_module_00/Warlock.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Warlock.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 20:37:27 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/04 13:04:30 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef WARLOCK_HPP 14 | # define WARLOCK_HPP 15 | 16 | # include 17 | # include 18 | 19 | class Warlock 20 | { 21 | private: 22 | std::string name; 23 | std::string title; 24 | 25 | Warlock(); 26 | Warlock(Warlock const &other); 27 | 28 | Warlock &operator=(Warlock const &other); 29 | public: 30 | Warlock(std::string const &name, std::string const &title); 31 | virtual ~Warlock(); 32 | 33 | std::string const &getName(void) const; 34 | std::string const &getTitle(void) const; 35 | 36 | void setTitle(std::string const &title); 37 | 38 | void introduce(void) const; 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /cpp_module_02/ASpell.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ASpell.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:06:00 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/11 11:41:51 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef ASPELL_HPP 14 | # define ASPELL_HPP 15 | 16 | # include 17 | # include 18 | 19 | class ATarget; 20 | 21 | class ASpell 22 | { 23 | protected: 24 | std::string name; 25 | std::string effects; 26 | public: 27 | ASpell(); 28 | ASpell(std::string const &name, std::string const &effects); 29 | ASpell(ASpell const &other); 30 | virtual ~ASpell(); 31 | 32 | ASpell &operator=(ASpell const &other); 33 | 34 | std::string const &getName(void) const; 35 | std::string const &getEffects(void) const; 36 | 37 | void launch(ATarget const &target); 38 | 39 | virtual ASpell *clone(void) const = 0; 40 | }; 41 | 42 | # include "ATarget.hpp" 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /cpp_module_01/ASpell.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ASpell.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:06:00 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/04 13:03:02 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef ASPELL_HPP 14 | # define ASPELL_HPP 15 | 16 | # include 17 | # include 18 | 19 | class ATarget; 20 | 21 | class ASpell 22 | { 23 | private: 24 | std::string name; 25 | std::string effects; 26 | public: 27 | ASpell(); 28 | ASpell(std::string const &name, std::string const &effects); 29 | ASpell(ASpell const &other); 30 | virtual ~ASpell(); 31 | 32 | ASpell &operator=(ASpell const &other); 33 | 34 | std::string const &getName(void) const; 35 | std::string const &getEffects(void) const; 36 | 37 | void launch(ATarget const &target) const; 38 | 39 | virtual ASpell *clone(void) const = 0; 40 | }; 41 | 42 | # include "ATarget.hpp" 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /cpp_module_00/Warlock.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Warlock.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 20:37:13 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:42:27 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "Warlock.hpp" 14 | 15 | Warlock::Warlock(std::string const &name, std::string const &title): 16 | name(name), title(title) { 17 | std::cout << this->name << ": What a boring day\n"; 18 | } 19 | 20 | Warlock::~Warlock() { 21 | std::cout << this->name << ": My job here is done!\n"; 22 | } 23 | 24 | std::string const &Warlock::getName(void) const { 25 | return (this->name); 26 | } 27 | 28 | std::string const &Warlock::getTitle(void) const { 29 | return (this->title); 30 | } 31 | 32 | void Warlock::setTitle(std::string const &title) { 33 | this->title = title; 34 | } 35 | 36 | void Warlock::introduce(void) const { 37 | std::cout << this->name << ": My name is " << this->name << ", " << this->title << "!\n"; 38 | } 39 | -------------------------------------------------------------------------------- /cpp_module_02/ASpell.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ASpell.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:05:57 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:40:26 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "ASpell.hpp" 14 | 15 | ASpell::ASpell(): 16 | name(), effects() {} 17 | 18 | ASpell::ASpell(std::string const &name, std::string const &effects): 19 | name(name), effects(effects) {} 20 | 21 | ASpell::ASpell(ASpell const &other): 22 | name(other.name), effects(other.effects) {} 23 | 24 | ASpell::~ASpell() {} 25 | 26 | ASpell &ASpell::operator=(ASpell const &other) { 27 | this->name = other.name; 28 | this->effects = other.effects; 29 | return (*this); 30 | } 31 | 32 | std::string const &ASpell::getName(void) const { 33 | return (this->name); 34 | } 35 | 36 | std::string const &ASpell::getEffects(void) const { 37 | return (this->effects); 38 | } 39 | 40 | void ASpell::launch(ATarget const &target) { 41 | target.getHitBySpell(*this); 42 | } 43 | -------------------------------------------------------------------------------- /cpp_module_01/ASpell.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ASpell.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 23:05:57 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:42:14 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "ASpell.hpp" 14 | 15 | ASpell::ASpell(): 16 | name(), effects() {} 17 | 18 | ASpell::ASpell(std::string const &name, std::string const &effects): 19 | name(name), effects(effects) {} 20 | 21 | ASpell::ASpell(ASpell const &other): 22 | name(other.name), effects(other.effects) {} 23 | 24 | ASpell::~ASpell() {} 25 | 26 | ASpell &ASpell::operator=(ASpell const &other) { 27 | this->name = other.name; 28 | this->effects = other.effects; 29 | return (*this); 30 | } 31 | 32 | std::string const &ASpell::getName(void) const { 33 | return (this->name); 34 | } 35 | 36 | std::string const &ASpell::getEffects(void) const { 37 | return (this->effects); 38 | } 39 | 40 | void ASpell::launch(ATarget const &target) const { 41 | target.getHitBySpell(*this); 42 | } 43 | -------------------------------------------------------------------------------- /cpp_module_01/Warlock.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Warlock.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 20:37:27 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/04 13:02:29 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef WARLOCK_HPP 14 | # define WARLOCK_HPP 15 | 16 | # include 17 | # include 18 | # include 19 | # include "ASpell.hpp" 20 | # include "ATarget.hpp" 21 | 22 | class Warlock 23 | { 24 | private: 25 | std::string name; 26 | std::string title; 27 | 28 | std::vector spells; 29 | 30 | Warlock(); 31 | Warlock(Warlock const &other); 32 | 33 | Warlock &operator=(Warlock const &other); 34 | public: 35 | Warlock(std::string const &name, std::string const &title); 36 | virtual ~Warlock(); 37 | 38 | std::string const &getName(void) const; 39 | std::string const &getTitle(void) const; 40 | 41 | void setTitle(std::string const &title); 42 | 43 | void introduce(void) const; 44 | 45 | void learnSpell(ASpell *spell); 46 | void forgetSpell(std::string const &spellName); 47 | void launchSpell(std::string const &spellName, ATarget const &target); 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /cpp_module_02/Warlock.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Warlock.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 20:37:27 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/04 13:00:44 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef WARLOCK_HPP 14 | # define WARLOCK_HPP 15 | 16 | # include 17 | # include 18 | # include 19 | # include "ASpell.hpp" 20 | # include "ATarget.hpp" 21 | # include "SpellBook.hpp" 22 | 23 | class Warlock 24 | { 25 | private: 26 | std::string name; 27 | std::string title; 28 | SpellBook spellBook; 29 | 30 | Warlock(); 31 | Warlock(Warlock const &other); 32 | 33 | Warlock &operator=(Warlock const &other); 34 | public: 35 | Warlock(std::string const &name, std::string const &title); 36 | virtual ~Warlock(); 37 | 38 | std::string const &getName(void) const; 39 | std::string const &getTitle(void) const; 40 | 41 | void setTitle(std::string const &title); 42 | 43 | void introduce(void) const; 44 | 45 | void learnSpell(ASpell *spell); 46 | void forgetSpell(std::string const &spellName); 47 | void launchSpell(std::string const &spellName, ATarget const &target); 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /cpp_module_01/main.cc: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.cc :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/17 00:35:12 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/04 13:09:40 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "Warlock.hpp" 14 | #include "Dummy.hpp" 15 | #include "Fwoosh.hpp" 16 | 17 | int main(void) 18 | { 19 | std::cout << "--- Constructors:\n"; 20 | 21 | Warlock richard("Richard", "Master of the Universe"); 22 | Fwoosh *spell = new Fwoosh(); 23 | Dummy targetPractice; 24 | 25 | std::cout << "--- \"Fwoosh\" not learned:\n"; 26 | 27 | richard.launchSpell("Fwoosh", targetPractice); 28 | 29 | std::cout << "--- \"Fwoosh\" learned:\n"; 30 | 31 | richard.learnSpell(spell); 32 | richard.launchSpell("Fwoosh", targetPractice); 33 | 34 | std::cout << "--- Forgotten \"Fwoosh\":\n"; 35 | 36 | richard.forgetSpell("Fwoosh"); 37 | richard.launchSpell("Fwoosh", targetPractice); 38 | 39 | std::cout << "--- Non-existant spell:\n"; 40 | 41 | richard.launchSpell("Splash", targetPractice); 42 | richard.forgetSpell("Splash"); 43 | richard.launchSpell("Splash", targetPractice); 44 | 45 | std::cout << "--- Destructors:\n"; 46 | return (0); 47 | } 48 | -------------------------------------------------------------------------------- /cpp_module_02/Warlock.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Warlock.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 20:37:13 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:39:43 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "Warlock.hpp" 14 | 15 | Warlock::Warlock(std::string const &name, std::string const &title): 16 | name(name), title(title) { 17 | std::cout << this->name << ": What a boring day\n"; 18 | } 19 | 20 | Warlock::~Warlock() { 21 | std::cout << this->name << ": My job here is done!\n"; 22 | } 23 | 24 | std::string const &Warlock::getName(void) const { 25 | return (this->name); 26 | } 27 | 28 | std::string const &Warlock::getTitle(void) const { 29 | return (this->title); 30 | } 31 | 32 | void Warlock::setTitle(std::string const &title) { 33 | this->title = title; 34 | } 35 | 36 | void Warlock::introduce(void) const { 37 | std::cout << this->name << ": My name is " << this->name << ", " << this->title << "!\n"; 38 | } 39 | 40 | void Warlock::learnSpell(ASpell *spell) { 41 | this->spellBook.learnSpell(spell); 42 | } 43 | 44 | void Warlock::forgetSpell(std::string const &spellName) { 45 | this->spellBook.forgetSpell(spellName); 46 | } 47 | 48 | void Warlock::launchSpell(std::string const &spellName, ATarget const &target) { 49 | ASpell *spell = this->spellBook.generateSpell(spellName); 50 | if (spell) 51 | spell->launch(target); 52 | } 53 | -------------------------------------------------------------------------------- /cpp_module_02/SpellBook.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* SpellBook.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/02/04 12:54:32 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:39:09 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "SpellBook.hpp" 14 | 15 | SpellBook::SpellBook() {} 16 | 17 | SpellBook::~SpellBook() { 18 | std::vector::iterator ite = this->spells.end(); 19 | for (std::vector::iterator it = this->spells.begin(); it != ite; ++it) 20 | delete *it; 21 | this->spells.clear(); 22 | } 23 | 24 | void SpellBook::learnSpell(ASpell *spell) { 25 | if (spell) { 26 | std::vector::iterator ite = this->spells.end(); 27 | for (std::vector::iterator it = this->spells.begin(); it != ite; ++it) 28 | if ((*it)->getName() == spell->getName()) 29 | return ; 30 | this->spells.push_back(spell->clone()); 31 | } 32 | } 33 | 34 | void SpellBook::forgetSpell(std::string const &spellName) { 35 | std::vector::iterator ite = this->spells.end(); 36 | for (std::vector::iterator it = this->spells.begin(); it != ite; ++it) { 37 | if ((*it)->getName() == spellName) { 38 | delete *it; 39 | it = this->spells.erase(it); 40 | } 41 | } 42 | } 43 | 44 | ASpell *SpellBook::generateSpell(std::string const &spellName) { 45 | std::vector::iterator ite = this->spells.end(); 46 | for (std::vector::iterator it = this->spells.begin(); it != ite; ++it) { 47 | if ((*it)->getName() == spellName) { 48 | return (*it); 49 | } 50 | } 51 | return (nullptr); 52 | } 53 | -------------------------------------------------------------------------------- /cpp_module_02/TargetGenerator.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* TargetGenerator.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/02/04 13:00:11 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:39:19 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "TargetGenerator.hpp" 14 | 15 | TargetGenerator::TargetGenerator() {} 16 | 17 | TargetGenerator::~TargetGenerator() { 18 | std::vector::iterator ite = this->types.end(); 19 | for (std::vector::iterator it = this->types.begin(); it != ite; ++it) 20 | delete *it; 21 | this->types.clear(); 22 | } 23 | 24 | void TargetGenerator::learnTargetType(ATarget *type) { 25 | if (type) { 26 | std::vector::iterator ite = this->types.end(); 27 | for (std::vector::iterator it = this->types.begin(); it != ite; ++it) 28 | if ((*it)->getType() == type->getType()) 29 | return ; 30 | this->types.push_back(type->clone()); 31 | } 32 | } 33 | 34 | void TargetGenerator::forgetTargetType(std::string const &name) { 35 | std::vector::iterator ite = this->types.end(); 36 | for (std::vector::iterator it = this->types.begin(); it != ite; ++it) { 37 | if ((*it)->getType() == name) { 38 | delete *it; 39 | it = this->types.erase(it); 40 | } 41 | } 42 | } 43 | 44 | ATarget *TargetGenerator::createTarget(std::string const &name) { 45 | std::vector::iterator ite = this->types.end(); 46 | for (std::vector::iterator it = this->types.begin(); it != ite; ++it) { 47 | if ((*it)->getType() == name) { 48 | return (*it); 49 | } 50 | } 51 | return (nullptr); 52 | } 53 | -------------------------------------------------------------------------------- /cpp_module_01/Warlock.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Warlock.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/16 20:37:13 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:50:14 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "Warlock.hpp" 14 | 15 | Warlock::Warlock(std::string const &name, std::string const &title): 16 | name(name), title(title) { 17 | std::cout << this->name << ": What a boring day\n"; 18 | } 19 | 20 | Warlock::~Warlock() { 21 | std::cout << this->name << ": My job here is done!\n"; 22 | std::vector::iterator ite = this->spells.end(); 23 | for (std::vector::iterator it = this->spells.begin(); it != ite; ++it) 24 | delete *it; 25 | this->spells.clear(); 26 | } 27 | 28 | std::string const &Warlock::getName(void) const { 29 | return (this->name); 30 | } 31 | 32 | std::string const &Warlock::getTitle(void) const { 33 | return (this->title); 34 | } 35 | 36 | void Warlock::setTitle(std::string const &title) { 37 | this->title = title; 38 | } 39 | 40 | void Warlock::introduce(void) const { 41 | std::cout << this->name << ": My name is " << this->name << ", " << this->title << "!\n"; 42 | } 43 | 44 | void Warlock::learnSpell(ASpell *spell) { 45 | if (spell) { 46 | std::vector::iterator ite = this->spells.end(); 47 | for (std::vector::iterator it = this->spells.begin(); it != ite; ++it) 48 | if ((*it)->getName() == spell->getName()) 49 | return ; 50 | this->spells.push_back(spell->clone()); 51 | } 52 | } 53 | 54 | void Warlock::forgetSpell(std::string const &spellName) { 55 | std::vector::iterator ite = this->spells.end(); 56 | for (std::vector::iterator it = this->spells.begin(); it != ite; ++it) { 57 | if ((*it)->getName() == spellName) { 58 | delete *it; 59 | it = this->spells.erase(it); 60 | } 61 | } 62 | } 63 | 64 | void Warlock::launchSpell(std::string const &spellName, ATarget const &target) { 65 | std::vector::iterator ite = this->spells.end(); 66 | for (std::vector::iterator it = this->spells.begin(); it != ite; ++it) { 67 | if ((*it)->getName() == spellName) { 68 | (*it)->launch(target); 69 | return ; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /cpp_module_02/main.cc: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.cc :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ncolomer +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/01/17 00:35:12 by ncolomer #+# #+# */ 9 | /* Updated: 2020/02/13 16:48:51 by ncolomer ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "Warlock.hpp" 14 | #include "Dummy.hpp" 15 | #include "BrickWall.hpp" 16 | #include "Fwoosh.hpp" 17 | #include "Fireball.hpp" 18 | #include "Polymorph.hpp" 19 | #include "TargetGenerator.hpp" 20 | 21 | int main(void) 22 | { 23 | std::cout << "--- Constructors:\n"; 24 | Warlock richard("Aang", "The Avatar"); 25 | 26 | std::cout << "--- Spells:\n"; 27 | Polymorph *water = new Polymorph(); 28 | Fireball *fire = new Fireball(); 29 | Fwoosh *air = new Fwoosh(); 30 | richard.learnSpell(water); 31 | richard.learnSpell(fire); 32 | richard.forgetSpell("Fwoosh"); 33 | richard.learnSpell(air); 34 | richard.forgetSpell("Fwoosh"); 35 | richard.forgetSpell("Fwoosh"); 36 | richard.learnSpell(air); 37 | 38 | std::cout << "--- Targets:\n"; 39 | Dummy *hay = new Dummy(); 40 | BrickWall *earth = new BrickWall(); 41 | 42 | TargetGenerator tarGen; 43 | tarGen.learnTargetType(hay); 44 | tarGen.learnTargetType(earth); 45 | 46 | std::cout << "--- Spells (all):\n"; 47 | 48 | richard.launchSpell("Fwoosh", *tarGen.createTarget("Dummy Practice")); 49 | richard.launchSpell("Fireball", *tarGen.createTarget("BrickWall Practice")); 50 | richard.launchSpell("Polymorph", *tarGen.createTarget("Dummy Practice")); 51 | 52 | std::cout << "--- Forgotten \"Fwoosh\":\n"; 53 | 54 | richard.forgetSpell("Fwoosh"); 55 | richard.launchSpell("Fwoosh", *tarGen.createTarget("Dummy Practice")); 56 | richard.launchSpell("Fireball", *tarGen.createTarget("BrickWall Practice")); 57 | richard.launchSpell("Polymorph", *tarGen.createTarget("Dummy Practice")); 58 | 59 | std::cout << "--- Spells (all):\n"; 60 | 61 | richard.learnSpell(air); 62 | richard.launchSpell("Fwoosh", *tarGen.createTarget("Dummy Practice")); 63 | richard.launchSpell("Fireball", *tarGen.createTarget("BrickWall Practice")); 64 | richard.launchSpell("Polymorph", *tarGen.createTarget("Dummy Practice")); 65 | 66 | std::cout << "--- Non-existant spell:\n"; 67 | 68 | richard.launchSpell("ACID", *tarGen.createTarget("BrickWall Practice")); 69 | richard.forgetSpell("ACID"); 70 | richard.launchSpell("ACID", *tarGen.createTarget("Dummy Practice")); 71 | 72 | std::cout << "--- Destructors:\n"; 73 | return (0); 74 | } 75 | --------------------------------------------------------------------------------