From d6876c53bb569c9c1abc9721ff0c16c0955e9a0b Mon Sep 17 00:00:00 2001 From: kinou-p Date: Sat, 6 Aug 2022 11:04:32 +0200 Subject: [PATCH] cpp05 end? --- cpp05/ex00/Bureaucrat.cpp | 11 ++- cpp05/ex00/Bureaucrat.hpp | 12 +-- cpp05/ex01/Bureaucrat.cpp | 14 +++- cpp05/ex01/Bureaucrat.hpp | 14 +--- cpp05/ex01/Form.cpp | 17 ++++- cpp05/ex01/Form.hpp | 17 +---- cpp05/ex02/AForm.cpp | 27 ++++++- cpp05/ex02/AForm.hpp | 25 ++---- cpp05/ex02/Bureaucrat.cpp | 16 +++- cpp05/ex02/Bureaucrat.hpp | 12 +-- cpp05/ex02/RobotomyRequestForm.cpp | 3 +- cpp05/ex02/ShrubberyCreationForm.cpp | 6 +- cpp05/ex02/main.cpp | 110 +++++++++++++++++++++++++-- cpp05/ex03/AForm.cpp | 3 +- cpp05/ex03/Bureaucrat.cpp | 3 +- cpp05/ex03/RobotomyRequestForm.cpp | 4 +- cpp05/ex03/main.cpp | 32 +++++++- 17 files changed, 235 insertions(+), 91 deletions(-) diff --git a/cpp05/ex00/Bureaucrat.cpp b/cpp05/ex00/Bureaucrat.cpp index a345240..36b580e 100644 --- a/cpp05/ex00/Bureaucrat.cpp +++ b/cpp05/ex00/Bureaucrat.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/18 21:34:42 by apommier #+# #+# */ -/* Updated: 2022/08/05 13:12:53 by apommier ### ########.fr */ +/* Updated: 2022/08/06 10:52:11 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -79,3 +79,12 @@ void Bureaucrat::checkGrade() const throw Bureaucrat::GradeTooHighException(); } +const char* Bureaucrat::GradeTooLowException::what() const throw() +{ + return ("Bureaucrat grade is too low\n"); +} + +const char* Bureaucrat::GradeTooHighException::what() const throw() +{ + return ("Bureaucrat grade is too high\n"); +} \ No newline at end of file diff --git a/cpp05/ex00/Bureaucrat.hpp b/cpp05/ex00/Bureaucrat.hpp index 56d665a..ba87ffc 100644 --- a/cpp05/ex00/Bureaucrat.hpp +++ b/cpp05/ex00/Bureaucrat.hpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/18 21:34:43 by apommier #+# #+# */ -/* Updated: 2022/07/19 11:23:31 by apommier ### ########.fr */ +/* Updated: 2022/08/06 10:51:46 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -35,19 +35,13 @@ class Bureaucrat{ class GradeTooLowException : public std::exception { public : - virtual const char* what() const throw() - { - return ("Bureaucrat grade is too low\n"); - } + virtual const char* what() const throw(); }; class GradeTooHighException : public std::exception { public : - virtual const char* what() const throw() - { - return ("Bureaucrat grade is too high\n"); - } + virtual const char* what() const throw(); }; private: diff --git a/cpp05/ex01/Bureaucrat.cpp b/cpp05/ex01/Bureaucrat.cpp index ba2bbf7..cf8938f 100644 --- a/cpp05/ex01/Bureaucrat.cpp +++ b/cpp05/ex01/Bureaucrat.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/18 21:34:42 by apommier #+# #+# */ -/* Updated: 2022/08/05 13:13:08 by apommier ### ########.fr */ +/* Updated: 2022/08/06 10:52:58 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -45,7 +45,7 @@ Bureaucrat &Bureaucrat::operator=(const Bureaucrat& rhs) std::ostream &operator<<(std::ostream &out, const Bureaucrat &bureaucrat) { - out << bureaucrat.getName() << ", bureaucrat grade " << bureaucrat.getGrade(); + out << bureaucrat.getName() << ", bureaucrat grade " << bureaucrat.getGrade() << std::endl; return (out); } @@ -90,3 +90,13 @@ void Bureaucrat::signForm(Form form) std::cout << this->_name << " couldn’t sign " << form.getName() << " form because "<< e.what(); } } + +const char* Bureaucrat::GradeTooLowException::what() const throw() +{ + return ("Bureaucrat grade is too low\n"); +} + +const char* Bureaucrat::GradeTooHighException::what() const throw() +{ + return ("Bureaucrat grade is too high\n"); +} diff --git a/cpp05/ex01/Bureaucrat.hpp b/cpp05/ex01/Bureaucrat.hpp index 5364ae5..30b1596 100644 --- a/cpp05/ex01/Bureaucrat.hpp +++ b/cpp05/ex01/Bureaucrat.hpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/18 21:34:43 by apommier #+# #+# */ -/* Updated: 2022/07/19 12:52:52 by apommier ### ########.fr */ +/* Updated: 2022/08/06 10:52:43 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -36,23 +36,17 @@ class Bureaucrat{ void checkGrade() const; void signForm(Form form); - + class GradeTooLowException : public std::exception { public : - virtual const char* what() const throw() - { - return ("Bureaucrat grade is too low\n"); - } + virtual const char* what() const throw(); }; class GradeTooHighException : public std::exception { public : - virtual const char* what() const throw() - { - return ("Bureaucrat grade is too high\n"); - } + virtual const char* what() const throw(); }; private: diff --git a/cpp05/ex01/Form.cpp b/cpp05/ex01/Form.cpp index 124f2f0..60fe70a 100644 --- a/cpp05/ex01/Form.cpp +++ b/cpp05/ex01/Form.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/19 11:54:01 by apommier #+# #+# */ -/* Updated: 2022/07/19 12:54:48 by apommier ### ########.fr */ +/* Updated: 2022/08/06 10:36:48 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -50,7 +50,7 @@ Form &Form::operator=(const Form& rhs) std::ostream &operator<<(std::ostream &out, const Form &form) { - out << form.getName() << "form need at least " << form.getSignedGrade() << " grade to be signed and "; + out << form.getName() << " form need at least " << form.getSignedGrade() << " grade to be signed and "; out << form.getExecutionGrade() << " grade to be executed, "; if (form.getIsSigned()) out << form.getName() << " form is signed\n"; @@ -98,4 +98,17 @@ void Form::checkGrade() const throw Form::GradeTooHighException(); } +const char* Form::GradeTooLowException::what() const throw() +{ + return ("Signed or Execution grade is too low\n"); +} +const char* Form::GradeTooHighException::what() const throw() +{ + return ("Signed or Execution grade is too high\n"); +} + +const char* Form::signedGradeTooLowException::what() const throw() +{ + return ("Signed grade is too low\n"); +} diff --git a/cpp05/ex01/Form.hpp b/cpp05/ex01/Form.hpp index d910716..2b4e85b 100644 --- a/cpp05/ex01/Form.hpp +++ b/cpp05/ex01/Form.hpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/19 11:54:09 by apommier #+# #+# */ -/* Updated: 2022/07/19 12:52:43 by apommier ### ########.fr */ +/* Updated: 2022/08/06 10:31:20 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,28 +41,19 @@ class Form{ class GradeTooLowException : public std::exception { public : - virtual const char* what() const throw() - { - return ("Signed or Execution grade is too low\n"); - } + virtual const char* what() const throw(); }; class GradeTooHighException : public std::exception { public : - virtual const char* what() const throw() - { - return ("Signed or Execution grade is too high\n"); - } + virtual const char* what() const throw(); }; class signedGradeTooLowException : public std::exception { public : - virtual const char* what() const throw() - { - return ("Signed grade is too low\n"); - } + virtual const char* what() const throw(); }; private : diff --git a/cpp05/ex02/AForm.cpp b/cpp05/ex02/AForm.cpp index bacfae4..914eddc 100644 --- a/cpp05/ex02/AForm.cpp +++ b/cpp05/ex02/AForm.cpp @@ -50,7 +50,7 @@ AForm &AForm::operator=(const AForm& rhs) std::ostream &operator<<(std::ostream &out, const AForm &Aform) { - out << Aform.getName() << "Aform need at least " << Aform.getSignedGrade() << " grade to be signed and "; + out << Aform.getName() << " Aform need at least " << Aform.getSignedGrade() << " grade to be signed and "; out << Aform.getExecutionGrade() << " grade to be executed, "; if (Aform.getIsSigned()) out << Aform.getName() << " Aform is signed\n"; @@ -102,8 +102,31 @@ void AForm::checkExecution(Bureaucrat const & executor) const { if (!this->_isSigned) throw AForm::formIsNotSignedException(); - else if (executor.getGrade() > this->_signedGrade) + else if (executor.getGrade() > this->_executionGrade) throw AForm::executionGradeTooLowException(); } +const char* AForm::GradeTooLowException::what() const throw() +{ + return ("Signed or Execution grade is too low\n"); +} +const char* AForm::GradeTooHighException::what() const throw() +{ + return ("Signed or Execution grade is too high\n"); +} + +const char* AForm::signedGradeTooLowException::what() const throw() +{ + return ("Signed grade is too low\n"); +} + +const char* AForm::executionGradeTooLowException::what() const throw() +{ + return ("Can't execute because Execution grade is too low\n"); +} + +const char* AForm::formIsNotSignedException::what() const throw() +{ + return ("Can't execute because Form isn't signed\n"); +} diff --git a/cpp05/ex02/AForm.hpp b/cpp05/ex02/AForm.hpp index c395855..9f739b1 100644 --- a/cpp05/ex02/AForm.hpp +++ b/cpp05/ex02/AForm.hpp @@ -43,46 +43,31 @@ class AForm{ class GradeTooLowException : public std::exception { public : - virtual const char* what() const throw() - { - return ("Signed or Execution grade is too low\n"); - } + virtual const char* what() const throw(); }; class GradeTooHighException : public std::exception { public : - virtual const char* what() const throw() - { - return ("Signed or Execution grade is too high\n"); - } + virtual const char* what() const throw(); }; class signedGradeTooLowException : public std::exception { public : - virtual const char* what() const throw() - { - return ("Signed grade is too low\n"); - } + virtual const char* what() const throw(); }; class executionGradeTooLowException : public std::exception { public : - virtual const char* what() const throw() - { - return ("Execution grade is too low\n"); - } + virtual const char* what() const throw(); }; class formIsNotSignedException : public std::exception { public : - virtual const char* what() const throw() - { - return ("Form isn't signed\n"); - } + virtual const char* what() const throw(); }; private : diff --git a/cpp05/ex02/Bureaucrat.cpp b/cpp05/ex02/Bureaucrat.cpp index ce3fd96..c3c02da 100644 --- a/cpp05/ex02/Bureaucrat.cpp +++ b/cpp05/ex02/Bureaucrat.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/18 21:34:42 by apommier #+# #+# */ -/* Updated: 2022/08/05 13:13:29 by apommier ### ########.fr */ +/* Updated: 2022/08/06 10:55:19 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -45,7 +45,7 @@ Bureaucrat &Bureaucrat::operator=(const Bureaucrat& rhs) std::ostream &operator<<(std::ostream &out, const Bureaucrat &bureaucrat) { - out << bureaucrat.getName() << ", bureaucrat grade " << bureaucrat.getGrade(); + out << bureaucrat.getName() << ", bureaucrat grade " << bureaucrat.getGrade() << std::endl; return (out); } @@ -94,5 +94,15 @@ void Bureaucrat::signForm(AForm &form) void Bureaucrat::executeForm(AForm const & form) const { form.execute(*this); - std::cout << " executed
" << std::endl; + std::cout << this->_name << " executed " << form.getName() << std::endl; +} + +const char* Bureaucrat::GradeTooLowException::what() const throw() +{ + return ("Bureaucrat grade is too low\n"); +} + +const char* Bureaucrat::GradeTooHighException::what() const throw() +{ + return ("Bureaucrat grade is too high\n"); } \ No newline at end of file diff --git a/cpp05/ex02/Bureaucrat.hpp b/cpp05/ex02/Bureaucrat.hpp index a53114e..ba97376 100644 --- a/cpp05/ex02/Bureaucrat.hpp +++ b/cpp05/ex02/Bureaucrat.hpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/18 21:34:43 by apommier #+# #+# */ -/* Updated: 2022/08/05 12:57:35 by apommier ### ########.fr */ +/* Updated: 2022/08/06 10:53:27 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,19 +41,13 @@ class Bureaucrat{ class GradeTooLowException : public std::exception { public : - virtual const char* what() const throw() - { - return ("Bureaucrat grade is too low\n"); - } + virtual const char* what() const throw(); }; class GradeTooHighException : public std::exception { public : - virtual const char* what() const throw() - { - return ("Bureaucrat grade is too high\n"); - } + virtual const char* what() const throw(); }; private: diff --git a/cpp05/ex02/RobotomyRequestForm.cpp b/cpp05/ex02/RobotomyRequestForm.cpp index ec3e136..4587910 100644 --- a/cpp05/ex02/RobotomyRequestForm.cpp +++ b/cpp05/ex02/RobotomyRequestForm.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/08/04 15:14:32 by apommier #+# #+# */ -/* Updated: 2022/08/04 18:54:53 by apommier ### ########.fr */ +/* Updated: 2022/08/05 16:14:19 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,6 +44,7 @@ void RobotomyRequestForm::execute(Bureaucrat const & executor) const { AForm::checkExecution(executor); std::cout << "Brrrzrzrzrzzrzrzzrrzz...\n"; + std::srand(time(NULL)); if (std::rand() % 2) std::cout << this->_target << " has been robotomized\n"; else diff --git a/cpp05/ex02/ShrubberyCreationForm.cpp b/cpp05/ex02/ShrubberyCreationForm.cpp index 2621c55..654a19d 100644 --- a/cpp05/ex02/ShrubberyCreationForm.cpp +++ b/cpp05/ex02/ShrubberyCreationForm.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/19 13:00:14 by apommier #+# #+# */ -/* Updated: 2022/08/04 19:44:50 by apommier ### ########.fr */ +/* Updated: 2022/08/06 11:00:31 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,10 +44,8 @@ ShrubberyCreationForm &ShrubberyCreationForm::operator=(const ShrubberyCreationF void ShrubberyCreationForm::execute(Bureaucrat const & executor) const { + AForm::checkExecution(executor); std::string name = this->_target + "_shrubbery"; - std::cout << name << std::endl; - (void)executor; - //AForm::checkExecution(executor); std::ofstream outfile(name.c_str()); outfile << " .\n . : \n . . :: :: \n . . ::: :: \n : : ::::. .. \n .. :: :: : ::. .:\n : ::: ::: . :: ::: .:.\n :: :::: . : :: ::: .::. \n ::: :: ::: : ::: .::.\n `::. ::: ::. `::::.::.\n `:::. :::. ::: :: :::::.\n `:::. ::bd:: :::::.\n `:::. :::. ::::. \n `::. `:::. :::: \n `:::. `::: :::: \n :::. :::: :::: \n ::bd:::bd:::: \n ::::::::::\n ::::::::\n :::(o): . . \n ::o:::(... \n `.. ::o:::: \n `):o:::: \n ::(o)::: \n .:::::: \n :::::::. \n :::::::::. \n ...::::::::::..."; } diff --git a/cpp05/ex02/main.cpp b/cpp05/ex02/main.cpp index 23b782a..aaf05e8 100644 --- a/cpp05/ex02/main.cpp +++ b/cpp05/ex02/main.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/18 21:34:45 by apommier #+# #+# */ -/* Updated: 2022/08/04 19:38:41 by apommier ### ########.fr */ +/* Updated: 2022/08/06 11:00:04 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,24 +18,120 @@ int main() { + std::cout << "===============================Presidential pardon=============================\n\n"; + std::cout << "Trying to execute without sign :\n"; try { - Bureaucrat First(151, "john"); + Bureaucrat john(150, "john"); + PresidentialPardonForm form("Assassin"); + john.executeForm(form); } catch(std::exception &e) { std::cout << e.what(); } - Bureaucrat First(1, "john"); - ShrubberyCreationForm test("niceTree"); + + std::cout << "\nTrying to execute without the right grade :\n"; try { - test.execute(First); + Bureaucrat john(25, "john"); + PresidentialPardonForm form("Assassin"); + form.beSigned(john); + john.executeForm(form); + } + catch(std::exception &e) + { + std::cout << e.what(); + } + + std::cout << "\nAll good :\n"; + try + { + Bureaucrat john(5, "john"); + PresidentialPardonForm form("Assassin"); + form.beSigned(john); + john.executeForm(form); + } + catch(std::exception &e) + { + std::cout << e.what(); + } + + std::cout << "\n===============================Robotomy request=============================\n\n"; + std::cout << "Trying to execute without sign :\n"; + try + { + Bureaucrat john(150, "john"); + RobotomyRequestForm form("Assassin"); + john.executeForm(form); + } + catch(std::exception &e) + { + std::cout << e.what(); + } + + std::cout << "\nTrying to execute without the right grade :\n"; + try + { + Bureaucrat john(46, "john"); + RobotomyRequestForm form("Assassin"); + form.beSigned(john); + john.executeForm(form); + } + catch(std::exception &e) + { + std::cout << e.what(); + } + + std::cout << "\nAll good :\n"; + try + { + Bureaucrat john(5, "john"); + RobotomyRequestForm form("Assassin"); + form.beSigned(john); + john.executeForm(form); + } + catch(std::exception &e) + { + std::cout << e.what(); + } + + std::cout << "\n===============================Shrubbery Creation=============================\n\n"; + std::cout << "Trying to execute without sign :\n"; + try + { + Bureaucrat john(150, "john"); + ShrubberyCreationForm form("Assassin"); + john.executeForm(form); + } + catch(std::exception &e) + { + std::cout << e.what(); + } + + std::cout << "\nTrying to execute without the right grade :\n"; + try + { + Bureaucrat john(138, "john"); + ShrubberyCreationForm form("Assassin"); + form.beSigned(john); + john.executeForm(form); + } + catch(std::exception &e) + { + std::cout << e.what(); + } + + std::cout << "\nAll good :\n"; + try + { + Bureaucrat john(137, "john"); + ShrubberyCreationForm form("Assassin"); + form.beSigned(john); + john.executeForm(form); } catch(std::exception &e) { std::cout << e.what(); } - - return (0); } \ No newline at end of file diff --git a/cpp05/ex03/AForm.cpp b/cpp05/ex03/AForm.cpp index 6819028..6593712 100644 --- a/cpp05/ex03/AForm.cpp +++ b/cpp05/ex03/AForm.cpp @@ -50,7 +50,7 @@ AForm &AForm::operator=(const AForm& rhs) std::ostream &operator<<(std::ostream &out, const AForm &Aform) { - out << Aform.getName() << "Aform need at least " << Aform.getSignedGrade() << " grade to be signed and "; + out << Aform.getName() << " Aform need at least " << Aform.getSignedGrade() << " grade to be signed and "; out << Aform.getExecutionGrade() << " grade to be executed, "; if (Aform.getIsSigned()) out << Aform.getName() << " Aform is signed\n"; @@ -121,7 +121,6 @@ const char* AForm::signedGradeTooLowException::what() const throw() return ("Signed grade is too low\n"); } - const char* AForm::executionGradeTooLowException::what() const throw() { return ("Can't execute because Execution grade is too low\n"); diff --git a/cpp05/ex03/Bureaucrat.cpp b/cpp05/ex03/Bureaucrat.cpp index 52a7217..f864f69 100644 --- a/cpp05/ex03/Bureaucrat.cpp +++ b/cpp05/ex03/Bureaucrat.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/18 21:34:42 by apommier #+# #+# */ -/* Updated: 2022/08/05 14:14:42 by apommier ### ########.fr */ +/* Updated: 2022/08/06 10:52:00 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -98,7 +98,6 @@ void Bureaucrat::executeForm(AForm const & form) const std::cout << this->_name << " executed " << form.getName() << std::endl; } - const char* Bureaucrat::GradeTooLowException::what() const throw() { return ("Bureaucrat grade is too low\n"); diff --git a/cpp05/ex03/RobotomyRequestForm.cpp b/cpp05/ex03/RobotomyRequestForm.cpp index 85a2ac6..68be1ff 100644 --- a/cpp05/ex03/RobotomyRequestForm.cpp +++ b/cpp05/ex03/RobotomyRequestForm.cpp @@ -6,12 +6,13 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/08/04 15:14:32 by apommier #+# #+# */ -/* Updated: 2022/08/05 14:30:26 by apommier ### ########.fr */ +/* Updated: 2022/08/05 16:13:44 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ #include "RobotomyRequestForm.hpp" #include +#include RobotomyRequestForm::RobotomyRequestForm() : AForm(72, 45, "RobotomyRequestForm") { @@ -44,6 +45,7 @@ void RobotomyRequestForm::execute(Bureaucrat const & executor) const { AForm::checkExecution(executor); std::cout << "Brrrzrzrzrzzrzrzzrrzz...\n"; + std::srand(time(NULL)); if (std::rand() % 2) std::cout << this->_target << " has been robotomized\n"; else diff --git a/cpp05/ex03/main.cpp b/cpp05/ex03/main.cpp index 80ddd32..a813f4c 100644 --- a/cpp05/ex03/main.cpp +++ b/cpp05/ex03/main.cpp @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/18 21:34:45 by apommier #+# #+# */ -/* Updated: 2022/08/05 14:46:57 by apommier ### ########.fr */ +/* Updated: 2022/08/06 11:02:04 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,6 +15,7 @@ #include "PresidentialPardonForm.hpp" #include "RobotomyRequestForm.hpp" #include "ShrubberyCreationForm.hpp" +#include "Intern.hpp" int main() { @@ -112,7 +113,7 @@ int main() std::cout << "\nTrying to execute without the right grade :\n"; try { - Bureaucrat john(137, "john"); + Bureaucrat john(138, "john"); ShrubberyCreationForm form("Assassin"); form.beSigned(john); john.executeForm(form); @@ -125,7 +126,7 @@ int main() std::cout << "\nAll good :\n"; try { - Bureaucrat john(5, "john"); + Bureaucrat john(137, "john"); ShrubberyCreationForm form("Assassin"); form.beSigned(john); john.executeForm(form); @@ -134,4 +135,29 @@ int main() { std::cout << e.what(); } + + std::cout << "\n===============================Intern tests=============================\n\n"; + Intern intern; + AForm *formPTR; + formPTR = intern.makeForm("not_a_form", "target"); + std::cout << formPTR << std::endl << std::endl; + formPTR = intern.makeForm("shrubbery creation", "garden"); + std::cout << *formPTR << std::endl; + formPTR = intern.makeForm("robotomy request", "ASmartGuy"); + std::cout << *formPTR << std::endl; + formPTR = intern.makeForm("presidential pardon", "Sinner"); + std::cout << *formPTR << std::endl; + + std::cout << "Execute created form :\n"; + try + { + Bureaucrat john(5, "john"); + formPTR->beSigned(john); + std::cout << *formPTR; + john.executeForm(*formPTR); + } + catch(std::exception &e) + { + std::cout << e.what(); + } } \ No newline at end of file