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