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.

58 lines
2.0 KiB

3 years ago
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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) {
cout << "Intern default constructor called " << endl;
}
Intern::Intern (Intern const & src) {
(void)src;
cout << "Intern copy constructor called" << endl;
}
Intern & Intern::operator= (Intern const & src) {
(void)src;
cout << "Intern assignment operator called" << endl;
return (*this);
}
Intern::~Intern (void) {
cout << "Intern default destructor called" << endl;
}
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);
}