You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

48 lines
1.8 KiB

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Intern.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/27 15:07:10 by narnaud #+# #+# */
/* Updated: 2022/06/27 16:28:56 by narnaud ### ########.fr */
/* */
/* ************************************************************************** */
#include "Intern.hpp"
Intern::Intern(void) {}
Intern::Intern(Intern const &src) { (void)src; }
Intern &Intern::operator=(Intern const &src) {
(void)src;
return (*this);
}
Intern::~Intern(void) {}
Form *createRobotForm(string targ) {
return (new RobotomyRequestForm(targ));
}
Form *createPresidentForm(string targ) {
return (new PresidentialPardonForm(targ));
}
Form *createShrubberyForm(string targ) {
return (new ShrubberyCreationForm(targ));
}
Form *Intern::makeForm(string name, string target) {
string subFormsName[3] = {"robotomy request", "president pardon",
"shrubbery creation"};
Form *(*subFormsCreation[3])(string targ) = {
createRobotForm, createPresidentForm, createShrubberyForm};
for (int i = 0; i < 3; i++)
if (name == subFormsName[i])
return (subFormsCreation[i](target));
cout << "Intern fail to create " << name << ": unknow form name" << endl;
return (NULL);
}