final
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
_-_
|
||||
/~~ ~~\
|
||||
/~~ ~~\
|
||||
{ }
|
||||
\ _- -_ /
|
||||
~ \\ // ~
|
||||
_- - | | _- _
|
||||
_ - | | -_
|
||||
// \\
|
||||
@@ -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
@@ -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)
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user