소스 검색

added 3 first exo of module05 expection

bastien 1 개월 전
부모
커밋
1c463abb8b

+ 50 - 0
Module_05/ex00/Makefile

@@ -0,0 +1,50 @@
+# **************************************************************************** #
+#                                                                              #
+#                                                         :::      ::::::::    #
+#    Makefile                                           :+:      :+:    :+:    #
+#                                                     +:+ +:+         +:+      #
+#    By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+         #
+#                                                 +#+#+#+#+#+   +#+            #
+#    Created: 2016/07/24 00:00:08 by bchanot           #+#    #+#              #
+#    Updated: 2025/12/29 16:14:46 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
+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

+ 62 - 0
Module_05/ex00/includes/Bureaucrat.hpp

@@ -0,0 +1,62 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   Bureaucrat.hpp                                     :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/26 17:51:13 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/29 16:31:34 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef BUREAUCRAT_HPP
+# define BUREAUCRAT_HPP
+
+# include <iostream>
+# include <string>
+# include <cstdint>
+
+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			decrementGrade(void);
+		void			incrementGrade(void);
+
+	private:
+		std::string		_name;
+		uint8_t	_grade;
+
+};
+
+std::ostream &			operator<<( std::ostream & o, Bureaucrat const & i );
+
+#endif /* ****************************************************** BUREAUCRAT_H */

+ 120 - 0
Module_05/ex00/srcs/Bureaucrat.cpp

@@ -0,0 +1,120 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   Bureaucrat.cpp                                     :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/26 17:51:13 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/29 16:35:46 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "Bureaucrat.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();
+}
+
+/*
+** --------------------------------- ACCESSOR ---------------------------------
+*/
+
+
+uint8_t		Bureaucrat::getGrade(void) const {
+	return this->_grade;
+}
+
+std::string		Bureaucrat::getName(void) const {
+	return this->_name;
+}
+
+/* ************************************************************************** */

+ 75 - 0
Module_05/ex00/srcs/main.cpp

@@ -0,0 +1,75 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   main.cpp                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/07/17 15:10:40 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/29 16:12:36 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "Bureaucrat.hpp"
+
+#include <iostream>
+#include <limits>
+
+int main( void ) {
+
+	Bureaucrat* bob = new Bureaucrat("bob", 150);
+	Bureaucrat* jimmy = new Bureaucrat("jimmy", 1);
+
+	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;
+
+	Bureaucrat* tooHigh;
+    try
+    {
+        tooHigh = new Bureaucrat("TooHigh", 0);
+    }
+    catch (std::exception & e)
+    {
+        std::cout << "Exception : " << e.what() << std::endl;
+    }
+    
+    Bureaucrat* tooLow;
+    try
+    {
+        tooLow = new Bureaucrat("TooLow", 151);
+    }
+    catch (std::exception & e)
+    {
+        std::cout << "Exception : " << e.what() << std::endl;
+    }
+	(void)tooLow;
+	(void)tooHigh;
+	delete (bob);
+	delete (jimmy);
+	return (0);
+}

+ 50 - 0
Module_05/ex01/Makefile

@@ -0,0 +1,50 @@
+# **************************************************************************** #
+#                                                                              #
+#                                                         :::      ::::::::    #
+#    Makefile                                           :+:      :+:    :+:    #
+#                                                     +:+ +:+         +:+      #
+#    By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+         #
+#                                                 +#+#+#+#+#+   +#+            #
+#    Created: 2016/07/24 00:00:08 by bchanot           #+#    #+#              #
+#    Updated: 2025/12/29 16:41:53 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 Form
+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

+ 65 - 0
Module_05/ex01/includes/Bureaucrat.hpp

@@ -0,0 +1,65 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   Bureaucrat.hpp                                     :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/26 17:51:13 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/30 14:00:54 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef BUREAUCRAT_HPP
+# define BUREAUCRAT_HPP
+
+# include <iostream>
+# include <string>
+# include <cstdint>
+
+class Form;
+
+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(Form &form);
+		void			decrementGrade(void);
+		void			incrementGrade(void);
+
+	private:
+		std::string		_name;
+		uint8_t			_grade;
+
+};
+
+std::ostream &			operator<<( std::ostream & o, Bureaucrat const & i );
+
+#endif /* ****************************************************** BUREAUCRAT_H */

+ 65 - 0
Module_05/ex01/includes/Form.hpp

@@ -0,0 +1,65 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   Form.hpp                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/29 16:42:01 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/30 14:00:46 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef FORM_HPP
+# define FORM_HPP
+
+# include <iostream>
+# include <string>
+# include <cstdint>
+
+class Bureaucrat;
+
+class Form
+{
+
+	public:
+
+		Form();
+		Form( Form const & src );
+		Form( std::string const name, uint8_t const signGrade, uint8_t const executeGrade );
+		~Form();
+
+		Form &		operator=( Form const & rhs );
+		
+		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;
+		uint8_t				getSignGrade(void) const;
+		uint8_t 			getExecutionGrade(void) const;
+		bool				getSigned(void) const;
+
+
+		void				beSigned(const Bureaucrat &sch);
+
+	private:
+		std::string const 	_name;
+		uint8_t	const		_signGrade;
+		uint8_t	const		_executeGrade;
+		bool				_signed;
+};
+
+std::ostream &			operator<<( std::ostream & o, Form const & i );
+
+#endif /* ************************************************************ FORM_H */

+ 131 - 0
Module_05/ex01/srcs/Bureaucrat.cpp

@@ -0,0 +1,131 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   Bureaucrat.cpp                                     :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/26 17:51:13 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/30 13:59:30 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "Bureaucrat.hpp"
+#include "Form.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(Form &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;
+	}
+}
+
+/*
+** --------------------------------- ACCESSOR ---------------------------------
+*/
+
+
+uint8_t		Bureaucrat::getGrade(void) const {
+	return this->_grade;
+}
+
+std::string		Bureaucrat::getName(void) const {
+	return this->_name;
+}
+
+/* ************************************************************************** */

+ 102 - 0
Module_05/ex01/srcs/Form.cpp

@@ -0,0 +1,102 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   Form.cpp                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/29 16:42:01 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/29 19:29:17 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "Form.hpp"
+#include "Bureaucrat.hpp"
+
+/*
+** ------------------------------- CONSTRUCTOR --------------------------------
+*/
+
+Form::Form() : _name("DefaultFormName"), _signGrade(1), _executeGrade(1), _signed(false)
+{
+}
+
+Form::Form( const std::string name, uint8_t execGrade, uint8_t signGrade ) : _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();
+}
+
+Form::Form( const Form & src ) : _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 --------------------------------
+*/
+
+Form::~Form()
+{
+}
+
+
+/*
+** --------------------------------- OVERLOAD ---------------------------------
+*/
+
+Form &				Form::operator=( Form const & rhs )
+{
+	(void)rhs;
+	//if ( this != &rhs )
+	//{
+		//this->_value = rhs.getValue();
+	//}
+	return *this;
+}
+
+std::ostream &			operator<<( std::ostream & o, Form const & i )
+{
+	o << "Form name : " << i.getName() << ", Minimum grade for sign : " << (int)i.getSignGrade() << ", Minimum exection grade : " << (int)i.getExecutionGrade() << ", Is signed : " << i.getSigned();
+	return o;
+}
+
+
+/*
+** --------------------------------- METHODS ----------------------------------
+*/
+
+void					Form::beSigned(const Bureaucrat &sch) {
+	if (sch.getGrade() <= this->_signGrade)
+		this->_signed = true;
+	else
+		throw Form::GradeTooLowException();
+}
+
+/*
+** --------------------------------- ACCESSOR ---------------------------------
+*/
+
+std::string	const		Form::getName(void) const {
+	return this->_name;
+}
+
+uint8_t				Form::getSignGrade(void) const {
+	return this->_signGrade;
+}
+
+uint8_t 			Form::getExecutionGrade(void) const {
+	return this->_executeGrade;
+}
+
+bool				Form::getSigned(void) const {
+	return this->_signed;
+}
+
+/* ************************************************************************** */

+ 106 - 0
Module_05/ex01/srcs/main.cpp

@@ -0,0 +1,106 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   main.cpp                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/07/17 15:10:40 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/29 19:26:11 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "Bureaucrat.hpp"
+#include "Form.hpp"
+
+#include <iostream>
+#include <limits>
+
+int main( void ) {
+		Bureaucrat* bob = new Bureaucrat("bob", 150);
+	Bureaucrat* jimmy = new Bureaucrat("jimmy", 1);
+	Form* form;
+
+	try
+	{
+		form = new Form("B_24", 150, 80);
+	}
+	catch (std::exception & e)
+	{
+		std::cout << "Exception " << e.what() << std::endl;
+	}
+
+	try
+	{
+		form = new Form("B_23", 160, 70);
+	}
+	catch (std::exception & e)
+	{
+		std::cout << "Exception " << e.what() << std::endl;
+	}
+
+	try
+	{
+		form = new Form("B_22", 0, 70);
+	}
+	catch (std::exception & e)
+	{
+		std::cout << "Exception " << e.what() << std::endl;
+	}
+
+	try
+	{
+		form = new Form("B_21", 80, 0);
+	}
+	catch (std::exception & e)
+	{
+		std::cout << "Exception " << e.what() << std::endl;
+	}
+
+	try
+	{
+		form = new Form("B_20", 70, 151);
+	}
+	catch (std::exception & e)
+	{
+		std::cout << "Exception " << e.what() << std::endl;
+	}
+
+	std::cout << *form << 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;
+
+	delete (bob);
+	delete (jimmy);
+	delete(form);
+	return (0);
+}

+ 50 - 0
Module_05/ex02/Makefile

@@ -0,0 +1,50 @@
+# **************************************************************************** #
+#                                                                              #
+#                                                         :::      ::::::::    #
+#    Makefile                                           :+:      :+:    :+:    #
+#                                                     +:+ +:+         +:+      #
+#    By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+         #
+#                                                 +#+#+#+#+#+   +#+            #
+#    Created: 2016/07/24 00:00:08 by bchanot           #+#    #+#              #
+#    Updated: 2025/12/30 18:08:18 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 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/ex02/forest_shrubbery

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

+ 69 - 0
Module_05/ex02/includes/AForm.hpp

@@ -0,0 +1,69 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   AForm.hpp                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/29 16:42:01 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/30 17:01:02 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 );
+		
+		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;
+		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/ex02/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 */

+ 38 - 0
Module_05/ex02/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/ex02/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/ex02/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 */

+ 109 - 0
Module_05/ex02/srcs/AForm.cpp

@@ -0,0 +1,109 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   AForm.cpp                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/29 16:42:01 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/30 18:29:19 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 )
+{
+	o << "AForm name : " << i.getName() << ", Minimum grade for sign : " << (int)i.getSignGrade() << ", Minimum exection grade : " << (int)i.getExecutionGrade() << ", Is signed : " << i.getSigned();
+	return o;
+}
+
+
+/*
+** --------------------------------- 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;
+}
+
+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/ex02/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;
+}
+
+/* ************************************************************************** */

+ 79 - 0
Module_05/ex02/srcs/PresidentialPardonForm.cpp

@@ -0,0 +1,79 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   PresidentialPardonForm.cpp                         :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/30 15:05:32 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/30 17:52:08 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 )
+{
+	(void)i;
+	//o << "Value = " << i.getValue();
+	return o;
+}
+
+
+/*
+** --------------------------------- METHODS ----------------------------------
+*/
+
+
+void		PresidentialPardonForm::action(void) const {
+	std::cout << this->_target << " has been pardoned by Zaphod Beeblebrox." << std::endl;
+}
+
+
+/*
+** --------------------------------- ACCESSOR ---------------------------------
+*/
+
+
+/* ************************************************************************** */

+ 85 - 0
Module_05/ex02/srcs/RobotomyRequestForm.cpp

@@ -0,0 +1,85 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   RobotomyRequestForm.cpp                            :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/30 15:05:32 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/30 17:51:31 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 )
+{
+	(void)i;
+	//o << "Value = " << i.getValue();
+	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 ---------------------------------
+*/
+
+
+/* ************************************************************************** */

+ 83 - 0
Module_05/ex02/srcs/ShrubberyCreationForm.cpp

@@ -0,0 +1,83 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ShrubberyCreationForm.cpp                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/12/30 15:05:32 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/30 17:51:52 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 )
+{
+	(void)i;
+	//o << "Value = " << i.getValue();
+	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 ---------------------------------
+*/
+
+
+/* ************************************************************************** */

+ 110 - 0
Module_05/ex02/srcs/main.cpp

@@ -0,0 +1,110 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   main.cpp                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2025/07/17 15:10:40 by bchanot           #+#    #+#             */
+/*   Updated: 2025/12/30 18:23:16 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "Bureaucrat.hpp"
+#include "AForm.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);
+	delete (bob);
+	delete (jimmy);
+	delete (form);
+	delete (roboform);
+	delete (shrubForm);
+	return (0);
+}