cpp05 end?
This commit is contained in:
parent
b17f78a802
commit
d6876c53bb
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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");
|
||||
}
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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:
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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");
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -40,19 +40,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:
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 :
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
@ -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 :
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 << "<bureaucrat> executed <form>" << 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");
|
||||
}
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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:
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 ...::::::::::...";
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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");
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
std::cout << e.what();
|
||||
}
|
||||
Bureaucrat First(1, "john");
|
||||
ShrubberyCreationForm test("niceTree");
|
||||
try
|
||||
{
|
||||
test.execute(First);
|
||||
Bureaucrat john(150, "john");
|
||||
PresidentialPardonForm form("Assassin");
|
||||
john.executeForm(form);
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
std::cout << e.what();
|
||||
}
|
||||
|
||||
return (0);
|
||||
std::cout << "\nTrying to execute without the right grade :\n";
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -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");
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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");
|
||||
|
||||
@ -6,12 +6,13 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 <cstdlib>
|
||||
#include <time.h>
|
||||
|
||||
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
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user