bastien 1 ay önce
ebeveyn
işleme
ff6f12a458

+ 3 - 1
Module_05/ex02/includes/AForm.hpp

@@ -6,7 +6,7 @@
 /*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2025/12/29 16:42:01 by bchanot           #+#    #+#             */
-/*   Updated: 2025/12/30 17:01:02 by bchanot          ###   ########.fr       */
+/*   Updated: 2025/12/31 16:04:33 by bchanot          ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -30,6 +30,7 @@ class AForm
 		virtual ~AForm();
 
 		AForm &		operator=( AForm const & rhs );
+		virtual void		print(std::ostream & o) const;
 		
 		class GradeTooHighException : public std::exception {
 			public:
@@ -46,6 +47,7 @@ class AForm
 		};
 
 		std::string	const	getName(void) const;
+		std::string	const	getTarget(void) const;
 		uint8_t				getSignGrade(void) const;
 		uint8_t 			getExecutionGrade(void) const;
 		bool				getSigned(void) const;

+ 10 - 2
Module_05/ex02/srcs/AForm.cpp

@@ -6,7 +6,7 @@
 /*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2025/12/29 16:42:01 by bchanot           #+#    #+#             */
-/*   Updated: 2025/12/30 18:29:19 by bchanot          ###   ########.fr       */
+/*   Updated: 2025/12/31 16:01:36 by bchanot          ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -63,10 +63,14 @@ AForm &				AForm::operator=( AForm const & rhs )
 
 std::ostream &			operator<<( std::ostream & o, AForm const & i )
 {
-	o << "AForm name : " << i.getName() << ", Minimum grade for sign : " << (int)i.getSignGrade() << ", Minimum exection grade : " << (int)i.getExecutionGrade() << ", Is signed : " << i.getSigned();
+	i.print(o);
 	return o;
 }
 
+void					AForm::print(std::ostream & o) const {
+	o << "AForm name : " << this->getName() << ", Minimum grade for sign : " << (int)this->getSignGrade() << ", Minimum exection grade : " << (int)this->getExecutionGrade() << ", Is signed : " << this->getSigned() << ", target : " << this->getTarget();
+}
+
 
 /*
 ** --------------------------------- METHODS ----------------------------------
@@ -94,6 +98,10 @@ std::string	const		AForm::getName(void) const {
 	return this->_name;
 }
 
+std::string	const		AForm::getTarget(void) const {
+	return this->_target;
+}
+
 uint8_t				AForm::getSignGrade(void) const {
 	return this->_signGrade;
 }

+ 2 - 3
Module_05/ex02/srcs/PresidentialPardonForm.cpp

@@ -6,7 +6,7 @@
 /*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2025/12/30 15:05:32 by bchanot           #+#    #+#             */
-/*   Updated: 2025/12/30 17:52:08 by bchanot          ###   ########.fr       */
+/*   Updated: 2025/12/31 16:04:56 by bchanot          ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -55,8 +55,7 @@ PresidentialPardonForm &				PresidentialPardonForm::operator=( PresidentialPardo
 
 std::ostream &			operator<<( std::ostream & o, PresidentialPardonForm const & i )
 {
-	(void)i;
-	//o << "Value = " << i.getValue();
+	i.print(o);
 	return o;
 }
 

+ 2 - 3
Module_05/ex02/srcs/RobotomyRequestForm.cpp

@@ -6,7 +6,7 @@
 /*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2025/12/30 15:05:32 by bchanot           #+#    #+#             */
-/*   Updated: 2025/12/30 17:51:31 by bchanot          ###   ########.fr       */
+/*   Updated: 2025/12/31 16:05:19 by bchanot          ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -56,8 +56,7 @@ RobotomyRequestForm &				RobotomyRequestForm::operator=( RobotomyRequestForm con
 
 std::ostream &			operator<<( std::ostream & o, RobotomyRequestForm const & i )
 {
-	(void)i;
-	//o << "Value = " << i.getValue();
+	i.print(o);
 	return o;
 }
 

+ 2 - 3
Module_05/ex02/srcs/ShrubberyCreationForm.cpp

@@ -6,7 +6,7 @@
 /*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2025/12/30 15:05:32 by bchanot           #+#    #+#             */
-/*   Updated: 2025/12/30 17:51:52 by bchanot          ###   ########.fr       */
+/*   Updated: 2025/12/31 16:05:27 by bchanot          ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -55,8 +55,7 @@ ShrubberyCreationForm &				ShrubberyCreationForm::operator=( ShrubberyCreationFo
 
 std::ostream &			operator<<( std::ostream & o, ShrubberyCreationForm const & i )
 {
-	(void)i;
-	//o << "Value = " << i.getValue();
+	i.print(o);
 	return o;
 }
 

+ 50 - 0
Module_05/ex03/Makefile

@@ -0,0 +1,50 @@
+# **************************************************************************** #
+#                                                                              #
+#                                                         :::      ::::::::    #
+#    Makefile                                           :+:      :+:    :+:    #
+#                                                     +:+ +:+         +:+      #
+#    By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+         #
+#                                                 +#+#+#+#+#+   +#+            #
+#    Created: 2016/07/24 00:00:08 by bchanot           #+#    #+#              #
+#    Updated: 2025/12/31 17:54:02 by bchanot          ###   ########.fr        #
+#                                                                              #
+# **************************************************************************** #
+
+NAME = a.out
+MAKE_LIBS = make --no-print-directory
+SRCS_DIR = srcs/
+OBJS_DIR = .objects/
+CC = g++ -Wall -Wextra -Werror -g
+INC = -I./includes
+FILES = main Bureaucrat AForm Intern PresidentialPardonForm RobotomyRequestForm ShrubberyCreationForm
+SRCS = $(FILES)
+OBJS = $(addprefix $(OBJS_DIR), $(addsuffix .o, $(SRCS)))
+RED = \033[1;31m
+BLUE = \033[1;34m
+CYAN = \033[0;36m
+GREEN = \033[1;32m
+YELLOW = \033[1;33m
+EOC = \033[0m
+
+all: $(NAME)
+
+$(NAME): $(OBJS)
+	@echo -e "$(GREEN)Objects created.$(EOC)"
+	@$(CC) $(OBJS) $(INC) -o $(NAME)
+	@echo -e "$(GREEN)Compilation complete.$(EOC)"
+
+$(OBJS_DIR)%.o: $(SRCS_DIR)%.cpp
+	@mkdir -p $(dir $@)
+	$(CC) -c $< $(INC) -o $@
+
+clean:
+	@echo -e "$(RED)Deleting objects.$(EOC)"
+	@/bin/rm -rf $(OBJS_DIR)
+
+fclean: clean
+	@echo -e "$(RED)Deleting binary.$(EOC)"
+	@/bin/rm -rf $(NAME)
+
+re: fclean all
+
+.PHONY: all clean fclean re

+ 1 - 0
Module_05/ex03/forest_shrubbery

@@ -0,0 +1 @@
+Beautiful ascii tree

+ 71 - 0
Module_05/ex03/includes/AForm.hpp

@@ -0,0 +1,71 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   AForm.hpp                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/29 16:42:01 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/31 16:04:33 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef AFORM_HPP
+# define AFORM_HPP
+
+# include <iostream>
+# include <string>
+# include <cstdint>
+
+class Bureaucrat;
+
+class AForm
+{
+
+	public:
+
+		AForm();
+		AForm( AForm const & src );
+		AForm( std::string const name, uint8_t const signGrade, uint8_t const executeGradea, std::string target );
+		virtual ~AForm();
+
+		AForm &		operator=( AForm const & rhs );
+		virtual void		print(std::ostream & o) const;
+		
+		class GradeTooHighException : public std::exception {
+			public:
+				virtual const char *what() const throw() {
+					return ("The grade specified is too high !");
+				}
+		};
+		
+		class GradeTooLowException : public std::exception {
+			public:
+				virtual const char *what() const throw() {
+					return ("The grade specified is too low !");
+				}
+		};
+
+		std::string	const	getName(void) const;
+		std::string	const	getTarget(void) const;
+		uint8_t				getSignGrade(void) const;
+		uint8_t 			getExecutionGrade(void) const;
+		bool				getSigned(void) const;
+
+		void				beSigned(const Bureaucrat &sch);
+		void				execute(Bureaucrat const & executor) const;
+
+	protected:
+		virtual void		action(void) const = 0;
+		std::string			_target;
+
+	private:
+		std::string const 	_name;
+		uint8_t	const		_signGrade;
+		uint8_t	const		_executeGrade;
+		bool				_signed;
+};
+
+std::ostream &			operator<<( std::ostream & o, AForm const & i );
+
+#endif /* ************************************************************ AFORM_H */

+ 66 - 0
Module_05/ex03/includes/Bureaucrat.hpp

@@ -0,0 +1,66 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   Bureaucrat.hpp                                     :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/26 17:51:13 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/30 18:23:58 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef BUREAUCRAT_HPP
+# define BUREAUCRAT_HPP
+
+# include <iostream>
+# include <string>
+# include <cstdint>
+
+class AForm;
+
+class Bureaucrat
+{
+
+	public:
+
+		Bureaucrat();
+		Bureaucrat( Bureaucrat const & src );
+		Bureaucrat( std::string const name, u_int8_t grade );
+		~Bureaucrat();
+
+		Bureaucrat 			&operator=( Bureaucrat const & rhs );
+		Bureaucrat			&operator++();
+		Bureaucrat			&operator--();
+
+		class GradeTooHighException : public std::exception {
+			public:
+				virtual const char *what() const throw() {
+					return ("The grade specified is too high !");
+				}
+		};
+		
+		class GradeTooLowException : public std::exception {
+			public:
+				virtual const char *what() const throw() {
+					return ("The grade specified is too low !");
+				}
+		};
+
+		uint8_t			getGrade(void) const;
+		std::string		getName(void) const;
+
+		void			signForm(AForm *form);
+		void			decrementGrade(void);
+		void			incrementGrade(void);
+		void			executeForm(AForm const & form) const;
+
+	private:
+		std::string		_name;
+		uint8_t			_grade;
+
+};
+
+std::ostream &			operator<<( std::ostream & o, Bureaucrat const & i );
+
+#endif /* ****************************************************** BUREAUCRAT_H */

+ 54 - 0
Module_05/ex03/includes/Intern.hpp

@@ -0,0 +1,54 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   Intern.hpp                                         :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/31 15:40:42 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/31 17:53:22 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef INTERN_HPP
+# define INTERN_HPP
+
+# include <iostream>
+# include <string>
+
+class AForm;
+#include "PresidentialPardonForm.hpp"
+#include "RobotomyRequestForm.hpp"
+#include "ShrubberyCreationForm.hpp"
+
+class Intern
+{
+
+	public:
+
+		Intern();
+		Intern( Intern const & src );
+		~Intern();
+
+		Intern &		operator=( Intern const & rhs );
+
+		class NotFoundException : public std::exception {
+			public:
+				virtual const char *what() const throw() {
+					return ("Cannot find the given Form");
+				}
+		};
+
+		AForm 		*makeForm(std::string const & name, std::string const & target);
+
+		AForm		*makePresidentialPardonForm(std::string const & target) const;
+		AForm		*makeRobotomyRequest(std::string const & target) const;
+		AForm		*makeShrubberyCreation(std::string const & target) const;
+
+	private:
+
+};
+
+std::ostream &			operator<<( std::ostream & o, Intern const & i );
+
+#endif /* ********************************************************** INTERN_H */

+ 38 - 0
Module_05/ex03/includes/PresidentialPardonForm.hpp

@@ -0,0 +1,38 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   PresidentialPardonForm.hpp                         :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/30 15:05:32 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/30 17:37:45 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef PRESIDENTIALPARDONFORM_HPP
+# define PRESIDENTIALPARDONFORM_HPP
+
+# include <iostream>
+# include <string>
+# include "AForm.hpp"
+
+class PresidentialPardonForm : public AForm
+{
+
+	public:
+
+		PresidentialPardonForm();
+		PresidentialPardonForm( PresidentialPardonForm const & src );
+		PresidentialPardonForm( std::string const & target );
+		~PresidentialPardonForm();
+
+		PresidentialPardonForm &		operator=( PresidentialPardonForm const & rhs );
+				
+	protected:
+		virtual void		action(void) const;
+};
+
+std::ostream &			operator<<( std::ostream & o, PresidentialPardonForm const & i );
+
+#endif /* ******************************************* PRESIDENTIALPARDONFORM_H */

+ 38 - 0
Module_05/ex03/includes/RobotomyRequestForm.hpp

@@ -0,0 +1,38 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   RobotomyRequestForm.hpp                            :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/30 15:05:32 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/30 16:58:14 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef ROBOTOMYREQUESTFORM_HPP
+# define ROBOTOMYREQUESTFORM_HPP
+
+# include <iostream>
+# include <string>
+# include "AForm.hpp"
+
+class RobotomyRequestForm : public AForm
+{
+
+	public:
+
+		RobotomyRequestForm();
+		RobotomyRequestForm( RobotomyRequestForm const & src );
+		RobotomyRequestForm( std::string const & target );
+		~RobotomyRequestForm();
+
+		RobotomyRequestForm &		operator=( RobotomyRequestForm const & rhs );
+		
+	protected:
+		virtual void		action(void) const;
+};
+
+std::ostream &			operator<<( std::ostream & o, RobotomyRequestForm const & i );
+
+#endif /* ******************************************* ROBOTOMYREQUESTFORM_H */

+ 38 - 0
Module_05/ex03/includes/ShrubberyCreationForm.hpp

@@ -0,0 +1,38 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ShrubberyCreationForm.hpp                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/30 15:05:32 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/30 16:58:20 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef SHRUBBERYCREATIONFORM_HPP
+# define SHRUBBERYCREATIONFORM_HPP
+
+# include <iostream>
+# include <string>
+# include "AForm.hpp"
+
+class ShrubberyCreationForm : public AForm
+{
+
+	public:
+
+		ShrubberyCreationForm();
+		ShrubberyCreationForm( ShrubberyCreationForm const & src );
+		ShrubberyCreationForm( std::string const & target );
+		~ShrubberyCreationForm();
+
+		ShrubberyCreationForm &		operator=( ShrubberyCreationForm const & rhs );
+				
+	protected:
+		virtual void		action(void) const;
+};
+
+std::ostream &			operator<<( std::ostream & o, ShrubberyCreationForm const & i );
+
+#endif /* ******************************************* SHRUBBERYCREATIONFORM_H */

+ 117 - 0
Module_05/ex03/srcs/AForm.cpp

@@ -0,0 +1,117 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   AForm.cpp                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/29 16:42:01 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/31 16:01:36 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "AForm.hpp"
+#include "Bureaucrat.hpp"
+
+/*
+** ------------------------------- CONSTRUCTOR --------------------------------
+*/
+
+AForm::AForm() : _target("DefautTarget"), _name("DefaultAFormName"), _signGrade(1), _executeGrade(1), _signed(false)
+{
+}
+
+AForm::AForm( const std::string name, uint8_t execGrade, uint8_t signGrade, std::string target) : _target(target), _name(name), _signGrade(signGrade), _executeGrade(execGrade), _signed(false)
+{
+	if (this->_executeGrade > 150 || this->_signGrade > 150)
+		throw Bureaucrat::GradeTooHighException();
+	else if (this->_executeGrade < 1 || this->_signGrade < 1)
+		throw Bureaucrat::GradeTooLowException();
+}
+
+AForm::AForm( const AForm & src ) : _target(src._target), _name(src._name), _signGrade(src._signGrade), _executeGrade(src._executeGrade), _signed(false)
+{
+	if (this->_executeGrade > 150 || this->_signGrade > 150)
+		throw Bureaucrat::GradeTooHighException();
+	else if (this->_executeGrade < 1 || this->_signGrade < 1)
+		throw Bureaucrat::GradeTooLowException();
+}
+
+
+/*
+** -------------------------------- DESTRUCTOR --------------------------------
+*/
+
+AForm::~AForm()
+{
+}
+
+
+/*
+** --------------------------------- OVERLOAD ---------------------------------
+*/
+
+AForm &				AForm::operator=( AForm const & rhs )
+{
+	(void)rhs;
+	//if ( this != &rhs )
+	//{
+		//this->_value = rhs.getValue();
+	//}
+	return *this;
+}
+
+std::ostream &			operator<<( std::ostream & o, AForm const & i )
+{
+	i.print(o);
+	return o;
+}
+
+void					AForm::print(std::ostream & o) const {
+	o << "AForm name : " << this->getName() << ", Minimum grade for sign : " << (int)this->getSignGrade() << ", Minimum exection grade : " << (int)this->getExecutionGrade() << ", Is signed : " << this->getSigned() << ", target : " << this->getTarget();
+}
+
+
+/*
+** --------------------------------- METHODS ----------------------------------
+*/
+
+void					AForm::beSigned(const Bureaucrat &sch) {
+	if (sch.getGrade() <= this->_signGrade)
+		this->_signed = true;
+	else
+		throw AForm::GradeTooLowException();
+}
+
+void					AForm::execute(Bureaucrat const & executor) const {
+	if (this->_signed && executor.getGrade() <= this->_signGrade && executor.getGrade() <= this->_executeGrade)
+		this->action();
+	else
+		throw AForm::GradeTooLowException();
+}
+
+/*
+** --------------------------------- ACCESSOR ---------------------------------
+*/
+
+std::string	const		AForm::getName(void) const {
+	return this->_name;
+}
+
+std::string	const		AForm::getTarget(void) const {
+	return this->_target;
+}
+
+uint8_t				AForm::getSignGrade(void) const {
+	return this->_signGrade;
+}
+
+uint8_t 			AForm::getExecutionGrade(void) const {
+	return this->_executeGrade;
+}
+
+bool				AForm::getSigned(void) const {
+	return this->_signed;
+}
+
+/* ************************************************************************** */

+ 140 - 0
Module_05/ex03/srcs/Bureaucrat.cpp

@@ -0,0 +1,140 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   Bureaucrat.cpp                                     :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/26 17:51:13 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/30 18:27:44 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "Bureaucrat.hpp"
+#include "AForm.hpp"
+
+/*
+** ------------------------------- CONSTRUCTOR --------------------------------
+*/
+
+Bureaucrat::Bureaucrat() : _name("DefaultName"), _grade(150)
+{
+}
+
+Bureaucrat::Bureaucrat( std::string const name, u_int8_t grade ) : _name(name), _grade(grade)
+{
+	if (this->_grade > 150)
+		throw Bureaucrat::GradeTooHighException();
+	else if (this->_grade < 1)
+		throw Bureaucrat::GradeTooLowException();
+}
+
+
+Bureaucrat::Bureaucrat( const Bureaucrat & src ) : _name(src._name), _grade(src._grade)
+{
+	if (this->_grade > 150)
+		throw Bureaucrat::GradeTooHighException();
+	else if (this->_grade < 1)
+		throw Bureaucrat::GradeTooLowException();
+}
+
+
+
+/*
+** -------------------------------- DESTRUCTOR --------------------------------
+*/
+
+Bureaucrat::~Bureaucrat()
+{
+}
+
+
+/*
+** --------------------------------- OVERLOAD ---------------------------------
+*/
+
+Bureaucrat &				Bureaucrat::operator=( Bureaucrat const & rhs )
+{
+	(void)rhs;
+	//if ( this != &rhs )
+	//{
+		//this->_value = rhs.getValue();
+	//}
+	return *this;
+}
+
+std::ostream &			operator<<( std::ostream & o, Bureaucrat const & i )
+{
+	o << i.getName() << ", bureaucrat grade " << (int)i.getGrade();
+	return o;
+}
+
+
+Bureaucrat		&Bureaucrat::operator++(void) {
+	if (this->_grade > 1)
+		this->_grade--;
+	else
+		throw Bureaucrat::GradeTooHighException();
+	return *this;
+}
+
+Bureaucrat		&Bureaucrat::operator--(void) {
+	if (this->_grade < 150)
+		this->_grade++;
+	else
+		throw Bureaucrat::GradeTooLowException();
+	return *this;
+}
+
+/*
+** --------------------------------- METHODS ----------------------------------
+*/
+
+void			Bureaucrat::decrementGrade(void)
+{
+	if (this->_grade < 150)
+		this->_grade++;
+	else
+		throw Bureaucrat::GradeTooHighException();
+}
+
+void			Bureaucrat::incrementGrade(void) {
+	if (this->_grade > 1)
+		this->_grade--;
+	else
+		throw Bureaucrat::GradeTooLowException();
+}
+
+void			Bureaucrat::signForm(AForm *form)
+{
+	try {
+		form->beSigned(*this);
+		std::cout << this->_name << " signed " << form->getName() <<  std::endl;
+	} catch (std::exception &e) {
+		std::cout << this->_name << " couldn't sign " << form->getName() << " because " << e.what() << std::endl;
+	}
+}
+
+void			Bureaucrat::executeForm(AForm const & form) const {
+	try {
+		form.execute(*this);
+		std::cout << this->_name << " executed " << form.getName() << std::endl;
+	} catch (std::exception & e) {
+		std::cout << this->_name << " failed to execute " << form.getName() << std::endl;
+	}
+}
+
+/*
+** --------------------------------- ACCESSOR ---------------------------------
+*/
+
+
+uint8_t		Bureaucrat::getGrade(void) const {
+	return this->_grade;
+}
+
+std::string		Bureaucrat::getName(void) const {
+	return this->_name;
+}
+
+/* ************************************************************************** */

+ 97 - 0
Module_05/ex03/srcs/Intern.cpp

@@ -0,0 +1,97 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   Intern.cpp                                         :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/31 15:40:42 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/31 17:59:26 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "Intern.hpp"
+
+/*
+** ------------------------------- CONSTRUCTOR --------------------------------
+*/
+
+Intern::Intern()
+{
+}
+
+Intern::Intern( const Intern & src )
+{
+	(void)src;
+}
+
+
+/*
+** -------------------------------- DESTRUCTOR --------------------------------
+*/
+
+Intern::~Intern()
+{
+}
+
+
+/*
+** --------------------------------- OVERLOAD ---------------------------------
+*/
+
+Intern &				Intern::operator=( Intern const & rhs )
+{
+	(void)rhs;
+	//if ( this != &rhs )
+	//{
+		//this->_value = rhs.getValue();
+	//}
+	return *this;
+}
+
+std::ostream &			operator<<( std::ostream & o, Intern const & i )
+{
+	(void)i;
+	//o << "Value = " << i.getValue();
+	return o;
+}
+
+
+/*
+** --------------------------------- METHODS ----------------------------------
+*/
+
+AForm	*Intern::makePresidentialPardonForm(std::string const & target) const { return new PresidentialPardonForm(target); }
+AForm	*Intern::makeRobotomyRequest(std::string const & target) const { return new RobotomyRequestForm(target); }
+AForm	*Intern::makeShrubberyCreation(std::string const & target) const { return new ShrubberyCreationForm(target); }
+
+AForm		*Intern::makeForm(std::string const & name, std::string const & target) {
+	size_t				size;
+	typedef AForm	*(Intern::*t_form)(std::string const & target) const;
+	typedef struct {std::string name; t_form createForm;} nameForm;
+	
+	nameForm tab[] = {
+		{"Presidential pardon", &Intern::makePresidentialPardonForm},
+		{"Robotomy request", &Intern::makeRobotomyRequest},
+		{"Shrubbery creation", &Intern::makeShrubberyCreation}
+	};
+
+	size = sizeof(tab)/sizeof(nameForm);
+
+	for (size_t i = 0; i < size; i++) {
+		if (name == tab[i].name) {
+			std::cout << "Intern creates " << name << std::endl;
+			return (this->*tab[i].createForm)(target);
+		}
+	}
+	std::cout << "Cannot find the form " << name << std::endl;
+	throw NotFoundException();
+}
+
+
+/*
+** --------------------------------- ACCESSOR ---------------------------------
+*/
+
+
+/* ************************************************************************** */

+ 78 - 0
Module_05/ex03/srcs/PresidentialPardonForm.cpp

@@ -0,0 +1,78 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   PresidentialPardonForm.cpp                         :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/30 15:05:32 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/31 16:04:56 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "PresidentialPardonForm.hpp"
+#include <fstream>
+
+/*
+** ------------------------------- CONSTRUCTOR --------------------------------
+*/
+
+PresidentialPardonForm::PresidentialPardonForm() : AForm("PresidentialPardonForm", 5, 25, "DefaultTargetForm")
+{
+}
+
+PresidentialPardonForm::PresidentialPardonForm( const std::string & target ) : AForm("PresidentialPardonForm", 5, 25, target)
+{
+}
+
+PresidentialPardonForm::PresidentialPardonForm( const PresidentialPardonForm & src ) : AForm(src.getName(), src.getSignGrade(), src.getExecutionGrade(), src._target)
+{
+}
+
+
+/*
+** -------------------------------- DESTRUCTOR --------------------------------
+*/
+
+PresidentialPardonForm::~PresidentialPardonForm()
+{
+}
+
+
+/*
+** --------------------------------- OVERLOAD ---------------------------------
+*/
+
+PresidentialPardonForm &				PresidentialPardonForm::operator=( PresidentialPardonForm const & rhs )
+{
+	(void)rhs;
+	//if ( this != &rhs )
+	//{
+		//this->_value = rhs.getValue();
+	//}
+	return *this;
+}
+
+std::ostream &			operator<<( std::ostream & o, PresidentialPardonForm const & i )
+{
+	i.print(o);
+	return o;
+}
+
+
+/*
+** --------------------------------- METHODS ----------------------------------
+*/
+
+
+void		PresidentialPardonForm::action(void) const {
+	std::cout << this->_target << " has been pardoned by Zaphod Beeblebrox." << std::endl;
+}
+
+
+/*
+** --------------------------------- ACCESSOR ---------------------------------
+*/
+
+
+/* ************************************************************************** */

+ 84 - 0
Module_05/ex03/srcs/RobotomyRequestForm.cpp

@@ -0,0 +1,84 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   RobotomyRequestForm.cpp                            :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/30 15:05:32 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/31 16:05:19 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "RobotomyRequestForm.hpp"
+#include <cstdlib>
+#include <ctime>
+
+/*
+** ------------------------------- CONSTRUCTOR --------------------------------
+*/
+
+RobotomyRequestForm::RobotomyRequestForm() : AForm("RobotomyRequestForm", 45, 72, "DefaultTarget")
+{
+}
+
+RobotomyRequestForm::RobotomyRequestForm( const std::string & target ) : AForm("RobotomyRequestForm", 45, 72, target)
+{
+}
+
+RobotomyRequestForm::RobotomyRequestForm( const RobotomyRequestForm & src ) : AForm(src.getName(), src.getSignGrade(), src.getExecutionGrade(), src._target)
+{
+}
+
+
+/*
+** -------------------------------- DESTRUCTOR --------------------------------
+*/
+
+RobotomyRequestForm::~RobotomyRequestForm()
+{
+}
+
+
+/*
+** --------------------------------- OVERLOAD ---------------------------------
+*/
+
+RobotomyRequestForm &				RobotomyRequestForm::operator=( RobotomyRequestForm const & rhs )
+{
+	(void)rhs;
+	//if ( this != &rhs )
+	//{
+		//this->_value = rhs.getValue();
+	//}
+	return *this;
+}
+
+std::ostream &			operator<<( std::ostream & o, RobotomyRequestForm const & i )
+{
+	i.print(o);
+	return o;
+}
+
+
+/*
+** --------------------------------- METHODS ----------------------------------
+*/
+
+
+void		RobotomyRequestForm::action(void) const {
+	srand(time(0));
+
+	if (rand() % 2)
+		std::cout << "*biiip bup biip, dzz dzzzzz* " << this->_target << " has been robotized successfully" << std::endl;
+	else
+		std::cout << "Oh.. Robotizing " << this->_target << " failed ... try again" << std::endl;
+}
+
+
+/*
+** --------------------------------- ACCESSOR ---------------------------------
+*/
+
+
+/* ************************************************************************** */

+ 82 - 0
Module_05/ex03/srcs/ShrubberyCreationForm.cpp

@@ -0,0 +1,82 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ShrubberyCreationForm.cpp                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/30 15:05:32 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/31 16:05:27 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "ShrubberyCreationForm.hpp"
+#include <fstream>
+
+/*
+** ------------------------------- CONSTRUCTOR --------------------------------
+*/
+
+ShrubberyCreationForm::ShrubberyCreationForm() : AForm("ShrubberyCreationForm", 137, 145, "DefaultTargetForm")
+{
+}
+
+ShrubberyCreationForm::ShrubberyCreationForm( const std::string & target ) : AForm("ShrubberyCreationForm", 137, 145, target)
+{
+}
+
+ShrubberyCreationForm::ShrubberyCreationForm( const ShrubberyCreationForm & src ) : AForm(src.getName(), src.getSignGrade(), src.getExecutionGrade(), src._target)
+{
+}
+
+
+/*
+** -------------------------------- DESTRUCTOR --------------------------------
+*/
+
+ShrubberyCreationForm::~ShrubberyCreationForm()
+{
+}
+
+
+/*
+** --------------------------------- OVERLOAD ---------------------------------
+*/
+
+ShrubberyCreationForm &				ShrubberyCreationForm::operator=( ShrubberyCreationForm const & rhs )
+{
+	(void)rhs;
+	//if ( this != &rhs )
+	//{
+		//this->_value = rhs.getValue();
+	//}
+	return *this;
+}
+
+std::ostream &			operator<<( std::ostream & o, ShrubberyCreationForm const & i )
+{
+	i.print(o);
+	return o;
+}
+
+
+/*
+** --------------------------------- METHODS ----------------------------------
+*/
+
+
+void		ShrubberyCreationForm::action(void) const {
+	std::string		const filename = this->_target + "_shrubbery";
+	std::ofstream	ofs(filename.c_str());
+
+	ofs << "Beautiful ascii tree" << std::endl;
+	ofs.close();
+}
+
+
+/*
+** --------------------------------- ACCESSOR ---------------------------------
+*/
+
+
+/* ************************************************************************** */

+ 132 - 0
Module_05/ex03/srcs/main.cpp

@@ -0,0 +1,132 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   main.cpp                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/07/17 15:10:40 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/31 17:59:20 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "Bureaucrat.hpp"
+#include "AForm.hpp"
+#include "Intern.hpp"
+#include "PresidentialPardonForm.hpp"
+#include "RobotomyRequestForm.hpp"
+#include "ShrubberyCreationForm.hpp"
+
+#include <iostream>
+#include <limits>
+
+int main( void ) {
+		srand(time(NULL));
+	Bureaucrat* bob = new Bureaucrat("bob", 150);
+	Bureaucrat* jimmy = new Bureaucrat("jimmy", 1);
+	PresidentialPardonForm* form;
+	ShrubberyCreationForm* shrubForm = new ShrubberyCreationForm("forest");
+	RobotomyRequestForm* roboform = new RobotomyRequestForm("Bill Potts");
+
+	try
+	{
+		form = new PresidentialPardonForm("Daphne");
+	}
+	catch (std::exception & e)
+	{
+		std::cout << "Exception " << e.what() << std::endl;
+	}
+	std::cout << *form << std::endl;
+	std::cout << *shrubForm << std::endl;
+	std::cout << *roboform << std::endl;
+	std::cout << *bob << std::endl;
+	std::cout << *jimmy << std::endl;
+
+	try
+	{
+		bob->incrementGrade();
+		jimmy->incrementGrade();
+	}
+	catch (std::exception & e)
+	{
+		std::cout << "Exception " << e.what() << std::endl;
+	}
+	std::cout << *bob << std::endl;
+	std::cout << *jimmy << std::endl;
+
+	try
+	{
+		jimmy->decrementGrade();
+		bob->decrementGrade();
+		bob->decrementGrade();
+	}
+	catch (std::exception & e)
+	{
+		std::cout << "Exception " << e.what() << std::endl;
+	}
+	std::cout << *bob << std::endl;
+	std::cout << *jimmy << std::endl;
+	bob->signForm(form);
+	jimmy->signForm(form);
+	std::cout << *form << std::endl;
+
+	bob->executeForm(*form);
+	jimmy->executeForm(*form);
+
+
+	bob->executeForm(*roboform);
+	jimmy->executeForm(*roboform);
+
+	bob->signForm(roboform);
+	jimmy->signForm(roboform);
+
+	bob->executeForm(*shrubForm);
+	bob->signForm(shrubForm);
+	jimmy->signForm(shrubForm);
+
+	try
+	{
+		int j = 0;
+		while (j++ < 20)
+			bob->incrementGrade();
+	}
+	catch (std::exception & e)
+	{
+		std::cout << "Exception " << e.what() << std::endl;
+	}
+
+	bob->executeForm(*shrubForm);
+
+	bob->executeForm(*roboform);
+	jimmy->executeForm(*roboform);
+	jimmy->executeForm(*roboform);
+	jimmy->executeForm(*roboform);
+	jimmy->executeForm(*roboform);
+
+
+	std::cout << "\n-------Last-Part--------\n" << std::endl;
+
+	Intern* nameless = new Intern;
+
+	std::cout << *nameless << std::endl;
+	AForm* creation;
+	try {
+	creation = nameless->makeForm("blue", "black");
+	} catch (std::exception & e) {
+		e.what();
+	}
+	creation = nameless->makeForm("Robotomy request", "red");
+	std::cout << *creation << std::endl;
+	jimmy->executeForm(*creation);
+	jimmy->signForm(creation);
+	jimmy->executeForm(*creation);
+
+	delete (bob);
+	delete (jimmy);
+	delete (form);
+	delete (roboform);
+	delete (shrubForm);
+	delete (creation);
+	delete (nameless);
+	return (0);
+}