This commit is contained in:
lfirmin
2025-12-17 23:58:30 +01:00
parent 2fef2f8dfc
commit d71a7eb045
11 changed files with 158 additions and 8 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ class AForm
AForm();
AForm(const std::string name, const int grade_si, const int grade_ex);
AForm(const AForm &other);
~AForm();
virtual ~AForm();
AForm &operator=(const AForm &other);
//mem
+9
View File
@@ -0,0 +1,9 @@
_-_
/~~ ~~\
/~~ ~~\
{ }
\ _- -_ /
~ \\ // ~
_- - | | _- _
_ - | | -_
// \\
+11
View File
@@ -3,6 +3,7 @@
#include "PresidentialPardonForm.hpp"
#include "RobotomyRequestForm.hpp"
#include "ShrubberyCreationForm.hpp"
#include "intern.hpp"
int main(void)
{
@@ -40,5 +41,15 @@ int main(void)
Mr_President.signForm(President_form);
Mr_President.executeForm(President_form);
std::cout << "\033[33m" << std::endl << "Test ex03 Intern" << "\033[0m" << std::endl;
Intern intern;
AForm *roboto;
roboto = intern.makeForm("DoYouKnowMe", "Hmmmm");
roboto = intern.makeForm("RobotomyRequestForm", "World");
std::cout << roboto->getName() << std::endl;
delete roboto;
return (0);
}
+2 -2
View File
@@ -1,9 +1,9 @@
CXX = c++
CXXFLAGS = -Wall -Wextra -Werror -std=c++98
OBJDIR = obj
SOURCES = Main.cpp Bureaucrat.cpp AForm.cpp PresidentialPardonForm.cpp RobotomyRequestForm.cpp ShrubberyCreationForm.cpp
SOURCES = Main.cpp Bureaucrat.cpp AForm.cpp PresidentialPardonForm.cpp RobotomyRequestForm.cpp ShrubberyCreationForm.cpp intern.cpp
OBJECTS = $(addprefix $(OBJDIR)/, $(SOURCES:.cpp=.o))
NAME = AForm
NAME = intern
all: $(NAME)
+49
View File
@@ -0,0 +1,49 @@
#include "intern.hpp"
#include "AForm.hpp"
#include "PresidentialPardonForm.hpp"
#include "RobotomyRequestForm.hpp"
#include "ShrubberyCreationForm.hpp"
// Constructors
Intern::Intern()
{
}
Intern::Intern(const Intern &other)
{
(void)other;
}
Intern &Intern::operator=(const Intern &other)
{
(void)other;
return (*this);
}
Intern::~Intern()
{
}
AForm *Intern::makeForm(const std::string form_name, const std::string form_target)
{
int i = 0;
std::string available_forms[] = {"ShrubberyCreationForm", "RobotomyRequestForm", "PresidentialPardonForm"};
while (i < 3 && form_name != available_forms[i])
i++;
switch (i) {
case 0:
std::cout << "Intern creates " << form_name << std::endl;
return (new ShrubberyCreationForm(form_target));
case 1:
std::cout << "Intern creates " << form_name << std::endl;
return (new RobotomyRequestForm(form_name));
case 2:
std::cout << "Intern creates " << form_name << std::endl;
return (new PresidentialPardonForm(form_target));
default:
std::cout << "Form is not existing" << std::endl;
return NULL;
}
}
+22
View File
@@ -0,0 +1,22 @@
#ifndef INTERN_HPP
#define INTERN_HPP
#include "AForm.hpp"
#include <exception>
#include <iostream>
#include <string>
class AForm;
class Intern
{
public:
Intern();
Intern(const Intern &other);
Intern &operator=(const Intern &other);
~Intern();
AForm *makeForm(const std::string form_name, const std::string form_target);
};
#endif