mise en page
This commit is contained in:
@@ -14,20 +14,32 @@ class Warlock {
|
||||
std::string title;
|
||||
|
||||
public:
|
||||
Warlock(std::string const & name, std::string const & title) {
|
||||
Warlock(std::string const & name, std::string const & title)
|
||||
{
|
||||
this->name = name;
|
||||
this->title = title;
|
||||
std::cout << this->name << ": This looks like another boring day.\n";
|
||||
};
|
||||
~Warlock() {
|
||||
~Warlock()
|
||||
{
|
||||
std::cout << this->name << ": My job here is done!\n";
|
||||
};
|
||||
|
||||
std::string const & getName() const {return (this->name);};
|
||||
std::string const & getTitle() const {return (this->title);};
|
||||
void setTitle(std::string const & title) {this->title = title;};
|
||||
std::string const & getName() const
|
||||
{
|
||||
return (this->name);
|
||||
};
|
||||
std::string const & getTitle() const
|
||||
{
|
||||
return (this->title);
|
||||
};
|
||||
void setTitle(std::string const & title)
|
||||
{
|
||||
this->title = title;
|
||||
};
|
||||
|
||||
void introduce() const {
|
||||
void introduce() const
|
||||
{
|
||||
std::cout << this->name << ": I am " << this->name << ", " << this->title << "!\n";
|
||||
};
|
||||
};
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
#include "ASpell.hpp"
|
||||
|
||||
void ASpell::launch(ATarget const & atarget) const {
|
||||
void ASpell::launch(ATarget const & atarget) const
|
||||
{
|
||||
atarget.getHitBySpell(*this);
|
||||
};
|
||||
|
||||
@@ -7,34 +7,41 @@
|
||||
class ATarget;
|
||||
|
||||
class ASpell {
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
std::string effects;
|
||||
|
||||
public:
|
||||
ASpell() {
|
||||
};
|
||||
ASpell(ASpell const & other) {
|
||||
ASpell()
|
||||
{};
|
||||
ASpell(ASpell const & other)
|
||||
{
|
||||
*this = other;
|
||||
};
|
||||
ASpell & operator=(ASpell const & other) {
|
||||
ASpell & operator=(ASpell const & other)
|
||||
{
|
||||
this->name = other.name;
|
||||
this->effects = other.effects;
|
||||
return (*this);
|
||||
};
|
||||
ASpell(std::string const & name, std::string const & effects) {
|
||||
ASpell(std::string const & name, std::string const & effects)
|
||||
{
|
||||
this->name = name;
|
||||
this->effects = effects;
|
||||
};
|
||||
virtual ~ASpell() {
|
||||
};
|
||||
virtual ~ASpell()
|
||||
{};
|
||||
|
||||
std::string const & getName() const {
|
||||
std::string const & getName() const
|
||||
{
|
||||
return (this->name);
|
||||
};
|
||||
std::string const & getEffects() const {
|
||||
std::string const & getEffects() const
|
||||
{
|
||||
return (this->effects);
|
||||
};
|
||||
|
||||
void launch(ATarget const & atarget) const;
|
||||
|
||||
virtual ASpell * clone() const = 0;
|
||||
@@ -43,3 +50,6 @@ class ASpell {
|
||||
#include "ATarget.hpp"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "ATarget.hpp"
|
||||
|
||||
void ATarget::getHitBySpell(ASpell const & aspell) const {
|
||||
void ATarget::getHitBySpell(ASpell const & aspell) const
|
||||
{
|
||||
std::cout << this->type << " has been " << aspell.getEffects() << "!\n";
|
||||
};
|
||||
|
||||
@@ -7,26 +7,33 @@
|
||||
class ASpell;
|
||||
|
||||
class ATarget {
|
||||
private:
|
||||
|
||||
private:
|
||||
std::string type;
|
||||
|
||||
public:
|
||||
ATarget() {
|
||||
};
|
||||
ATarget(ATarget const & other) {
|
||||
ATarget()
|
||||
{};
|
||||
ATarget(ATarget const & other)
|
||||
{
|
||||
*this = other;
|
||||
};
|
||||
ATarget & operator=(ATarget const & other) {
|
||||
ATarget & operator=(ATarget const & other)
|
||||
{
|
||||
this->type = other.type;
|
||||
return (*this);
|
||||
};
|
||||
ATarget(std::string const & type) {
|
||||
ATarget(std::string const & type)
|
||||
{
|
||||
this->type = type;
|
||||
};
|
||||
~ATarget() {};
|
||||
~ATarget()
|
||||
{};
|
||||
|
||||
std::string const & getType() const {return (this->type);};
|
||||
std::string const & getType() const
|
||||
{
|
||||
return (this->type);
|
||||
};
|
||||
|
||||
void getHitBySpell(ASpell const & aspell) const;
|
||||
|
||||
|
||||
@@ -4,11 +4,15 @@
|
||||
# include "ATarget.hpp"
|
||||
|
||||
class Dummy: public ATarget {
|
||||
public:
|
||||
Dummy(): ATarget("Target Practice Dummy") {};
|
||||
~Dummy() {};
|
||||
|
||||
virtual ATarget * clone() const {
|
||||
public:
|
||||
Dummy(): ATarget("Target Practice Dummy")
|
||||
{};
|
||||
~Dummy()
|
||||
{};
|
||||
|
||||
virtual ATarget * clone() const
|
||||
{
|
||||
return (new Dummy());
|
||||
};
|
||||
};
|
||||
|
||||
@@ -4,11 +4,15 @@
|
||||
# include "ASpell.hpp"
|
||||
|
||||
class Fwoosh: public ASpell {
|
||||
public:
|
||||
Fwoosh(): ASpell("Fwoosh", "fwooshed") {};
|
||||
~Fwoosh() {};
|
||||
|
||||
virtual ASpell * clone() const {
|
||||
public:
|
||||
Fwoosh(): ASpell("Fwoosh", "fwooshed")
|
||||
{};
|
||||
~Fwoosh()
|
||||
{};
|
||||
|
||||
virtual ASpell * clone() const
|
||||
{
|
||||
return (new Fwoosh());
|
||||
};
|
||||
};
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
|
||||
# include <iostream>
|
||||
# include <string>
|
||||
# include "ASpell.hpp"
|
||||
# include "ATarget.hpp"
|
||||
# include <map>
|
||||
|
||||
# include "ASpell.hpp"
|
||||
# include "ATarget.hpp"
|
||||
|
||||
class Warlock {
|
||||
|
||||
private:
|
||||
Warlock();
|
||||
Warlock(Warlock const & other);
|
||||
@@ -18,12 +20,14 @@ class Warlock {
|
||||
std::map<std::string, ASpell *> arr;
|
||||
|
||||
public:
|
||||
Warlock(std::string const & name, std::string const & title) {
|
||||
Warlock(std::string const & name, std::string const & title)
|
||||
{
|
||||
this->name = name;
|
||||
this->title = title;
|
||||
std::cout << this->name << ": This looks like another boring day.\n";
|
||||
};
|
||||
~Warlock() {
|
||||
~Warlock()
|
||||
{
|
||||
std::cout << this->name << ": My job here is done!\n";
|
||||
std::map<std::string, ASpell *>::iterator it_begin = this->arr.begin();
|
||||
std::map<std::string, ASpell *>::iterator it_end = this->arr.end();
|
||||
@@ -34,30 +38,46 @@ class Warlock {
|
||||
this->arr.clear();
|
||||
};
|
||||
|
||||
std::string const & getName() const {return (this->name);};
|
||||
std::string const & getTitle() const {return (this->title);};
|
||||
std::string const & getName() const
|
||||
{
|
||||
return (this->name);
|
||||
};
|
||||
std::string const & getTitle() const
|
||||
{
|
||||
return (this->title);
|
||||
};
|
||||
|
||||
void setTitle(std::string const & title) {this->title = title;};
|
||||
void setTitle(std::string const & title)
|
||||
{
|
||||
this->title = title;
|
||||
};
|
||||
|
||||
void introduce() const {
|
||||
void introduce() const
|
||||
{
|
||||
std::cout << this->name << ": I am " << this->name << ", " << this->title << "!\n";
|
||||
};
|
||||
|
||||
void learnSpell(ASpell * aspell) {
|
||||
void learnSpell(ASpell * aspell)
|
||||
{
|
||||
if (aspell)
|
||||
arr.insert(std::pair<std::string, ASpell *>(
|
||||
{
|
||||
arr.insert(std::pair<std::string, ASpell *>
|
||||
(
|
||||
aspell->getName(),
|
||||
aspell->clone()
|
||||
));
|
||||
}
|
||||
};
|
||||
void forgetSpell(std::string name) {
|
||||
void forgetSpell(std::string name)
|
||||
{
|
||||
std::map<std::string, ASpell *>::iterator it = arr.find(name);
|
||||
if (it == arr.end())
|
||||
return;
|
||||
delete it->second;
|
||||
arr.erase(name);
|
||||
};
|
||||
void launchSpell(std::string name, ATarget const & target) {
|
||||
void launchSpell(std::string name, ATarget const & target)
|
||||
{
|
||||
ASpell * spell = arr[name];
|
||||
if (spell)
|
||||
spell->launch(target);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user