| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* 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);
- }
|