1
0

」 feat: finished ex03

This commit is contained in:
2025-04-03 16:07:05 +02:00
parent bb8d13b9ed
commit bd578ea11e
17 changed files with 811 additions and 5 deletions

63
ex03/Intern.cpp Normal file
View File

@ -0,0 +1,63 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Intern.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/03 15:24:46 by adjoly #+# #+# */
/* Updated: 2025/04/03 15:57:18 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "Intern.hpp"
#include "Bureaucrat.hpp"
#include "PresidentialPardonForm.hpp"
#include "RobotomyRequestForm.hpp"
#include "ShrubberyCreationForm.hpp"
#include <cstddef>
Intern::Intern(void) {
_log("", "Intern", "", "default constructor called");
}
Intern::Intern(const Intern &cpy) {
_log("", "Intern", "", "copy constructor called");
*this = cpy;
}
Intern::~Intern(void) {
_log("", "Intern", "", "destructor called");
}
Intern &Intern::operator=(const Intern &) {
_log("", "Intern", "", "copy assignement constructor called");
return *this;
}
AForm *newShrubbery(std::string &target) {
return new ShrubberyCreationForm(target);
}
AForm *newPresidential(std::string &target) {
return new PresidentialPardonForm(target);
}
AForm *newRobotomy(std::string &target) {
return new RobotomyRequestForm(target);
}
AForm *Intern::makeForm(std::string name, std::string target) const {
std::string formName[] = {"robotomy request", "shrubbery request", "presidential pardon request"};
AForm *(*newForm[])(std::string &) = {&newRobotomy, &newShrubbery, &newPresidential};
for (size_t i = 0; i < 3; i++) {
if (formName[i] == name) {
AForm *n = newForm[i](target);
std::cout << "Intern creates " << name << std::endl;
return n;
}
}
std::cerr << "Intern doesn't know " << name << std::endl;
return NULL;
}