diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-11-17 19:02:35 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-11-17 19:02:35 +0100 |
| commit | 452e6bfa7bb4bca75dc4659bf9d707101b411977 (patch) | |
| tree | f4ee27a96437d6d17a89bbbbc135ae45f9f3faae /cpp05/ex03/Intern.cpp | |
| parent | a92013c92bfcd50b0e2561280c9eaa604843ade0 (diff) | |
| download | piscine_cpp-452e6bfa7bb4bca75dc4659bf9d707101b411977.tar.gz piscine_cpp-452e6bfa7bb4bca75dc4659bf9d707101b411977.tar.bz2 piscine_cpp-452e6bfa7bb4bca75dc4659bf9d707101b411977.zip | |
Added cpp05/ex02 main, Added cpp05/ex03
Diffstat (limited to 'cpp05/ex03/Intern.cpp')
| -rw-r--r-- | cpp05/ex03/Intern.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/cpp05/ex03/Intern.cpp b/cpp05/ex03/Intern.cpp index bb3e188..3328957 100644 --- a/cpp05/ex03/Intern.cpp +++ b/cpp05/ex03/Intern.cpp @@ -6,18 +6,37 @@ /* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/11/17 13:41:09 by cacharle #+# #+# */ -/* Updated: 2020/11/17 13:48:01 by cacharle ### ########.fr */ +/* Updated: 2020/11/17 18:08:56 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include "Intern.hpp" Intern::Intern() {} -Intern::Intern(const Intern& other) {} -Intern& Intern::operator=(const Intern& other) {} +Intern::Intern(const Intern& other) { (void)other; } +Intern& Intern::operator=(const Intern& other) { (void)other; return *this; } Intern::~Intern() {} -Form *Intern::makeForm(std::string const& name, std::string const& target) +Form *Intern::makeShrubberyCreationForm(std::string const& target) + { return new ShrubberyCreationForm(target); } + +Form *Intern::makePresidentialPardonForm(std::string const& target) + { return new PresidentialPardonForm(target); } + +Form *Intern::makeRobotomyRequestForm(std::string const& target) + { return new RobotomyRequestForm(target); } + +Intern::makeFormEntry Intern::makeFormDispatch[] = { + {"shrubbery creation", &Intern::makeShrubberyCreationForm}, + {"presidential pardon", &Intern::makePresidentialPardonForm}, + {"robotomy request", &Intern::makeRobotomyRequestForm}, +}; +Form *Intern::makeForm(std::string const& name, std::string const& target) +{ + for (size_t i = 0; i < sizeof(Intern::makeFormDispatch) / sizeof(Intern::makeFormEntry); i++) + if ((this->makeFormDispatch[i]).name == name) + return (this->*(makeFormDispatch[i].func))(target); + return NULL; } |
