mise en page

This commit is contained in:
lenovo
2022-12-09 13:39:46 +01:00
parent c91d23a5d4
commit fecde1a8b1
12 changed files with 104 additions and 45 deletions

View File

@@ -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);