🎉」 init: hello world !

This commit is contained in:
2025-08-02 13:51:40 +02:00
commit 224ed0cf99
44 changed files with 2108 additions and 0 deletions

52
ex03/Intern.cpp Normal file
View File

@@ -0,0 +1,52 @@
#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;
}