-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntern.cpp
More file actions
70 lines (60 loc) · 1.94 KB
/
Intern.cpp
File metadata and controls
70 lines (60 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Intern.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zelhajou <zelhajou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/27 17:12:22 by zelhajou #+# #+# */
/* Updated: 2024/12/30 13:38:09 by zelhajou ### ########.fr */
/* */
/* ************************************************************************** */
#include "Intern.hpp"
Intern::Intern() {}
Intern::Intern(const Intern &src)
{
*this = src;
}
Intern::~Intern() {}
Intern &Intern::operator=(const Intern &src)
{
(void)src;
return *this;
}
AForm *Intern::makeForm(const std::string &formName, const std::string &target)
{
const std::string formTypes[3] = {
"shrubbery creation",
"robotomy request",
"presidential pardon"};
int j = -1;
for (int i = 0; i < 3; i++)
{
if (formName == formTypes[i])
{
j = i;
break;
}
}
AForm *form = NULL;
switch (j)
{
case 0:
form = new ShrubberyCreationForm(target);
break;
case 1:
form = new RobotomyRequestForm(target);
break;
case 2:
form = new PresidentialPardonForm(target);
break;
default:
throw FormNotFoundException();
}
std::cout << "Intern creates " << formName << std::endl;
return form;
}
const char *Intern::FormNotFoundException::what() const throw()
{
return "Error: Form type not found";
}