53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
#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;
|
||
}
|
||
|