|
@@ -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);
|
|
|
|
|
+}
|