Пример #1
0
void			Form::beSigned( Bureaucrat & bureau )
{
		if (bureau.getGrade() > this->_sign_grade )
			throw Form::GradeTooLowException();
		else
			this->_status = true;
}
Пример #2
0
void				Form::beSigned(Bureaucrat const & bureaucrat) {

	if (bureaucrat.getGrade() <= this->_signGrade)
		this->_signed = true;
	else
		throw Form::GradeTooLowException();
}
void			PresidentialPardonForm::execute(Bureaucrat const & executor) const
{
	if (executor.getGrade() > PresidentialPardonForm::_PresidentialExecute)
		throw Form::BureaucratNotClearForExecution();
	else
		std::cout << this->_target << " has been pardoned by Zafod Beeblebrox.\n";
}
Пример #4
0
bool	Form::execute(Bureaucrat const & executor) const
{
	try
	{
		if (executor.getGrade() > this->_grade)
		{
			throw Form::GradeTooLowException();
			return (0);
		}
		else if (this->_signed == 0)
		{
			throw Form::FormNotSignedException();
			return (0);
		}
		else
		{
			this->Action();
			return (1);
		}
	}
	catch(Form::GradeTooLowException& e)
	{
		std::cout << e.what() << std::endl;
		return(0);
	}
	catch(Form::FormNotSignedException& e)
	{
		std::cout << e.what() << std::endl;
		return(0);
	}
	return (0);
}
Пример #5
0
void				Form::execute(Bureaucrat const & executor) const {
	if (!this->getSigned() || executor.getGrade() > this->getExeGrade())
		throw Form::GradeTooLowException();
	else {
		this->action();
	}
}
Пример #6
0
void Form::beSigned(Bureaucrat & p_bureaucrat)
{
	if (p_bureaucrat.getGrade() <= mn_gradeToSign)
		mb_isSigned = true;
	else
		throw Form::GradeTooLowException();
}
Пример #7
0
void			Form::beSigned(Bureaucrat& b)
{
	if (b.getGrade() <= m_sgrade)
		m_sign = 1;
	else
		throw GradeTooLowException();
	return;
}
Пример #8
0
void	Form::execute(const Bureaucrat& executor) const
{
	if (executor.getGrade() > _grade_to_execute) {
		throw Form::GradeTooLowException();
	} else if (!_is_signed) {
		throw Form::NotSignedException();
	}
}
Пример #9
0
void				Form::execute(Bureaucrat const &b) const
	throw(GradeTooLowException)
{
	if (b.getGrade() <= gradeExec && sign)
		action();
	else
		throw GradeTooLowException();
}
Пример #10
0
void Form::beSigned(Bureaucrat &src) {
    if (src.getGrade() <= this->gradeSign) {
        this->validated = true;
    }
    else {
        throw GradeTooLowException();
    }
}
Пример #11
0
void	Form::beSigned(Bureaucrat& b)
{
	if (b.getGrade() < _grade_to_sign) {
		_is_signed = true;
	} else {
		throw Form::GradeTooLowException();
	}
}
Пример #12
0
void				Form::beSigned(Bureaucrat const &b)
	throw(GradeTooLowException)
{
	if (b.getGrade() <= gradeSign)
		sign = true;
	else
		throw GradeTooLowException();
}
Пример #13
0
void Form::beSigned(Bureaucrat & bureaucrat)
{
	if (bureaucrat.getGrade() > _gradeSign) // Si le bureaucrat ne peut pas sign form
	{
		throw Form::GradeTooLowException();
	}
	else
		_isSigned = true;
}
Пример #14
0
void					Form::beSigned(Bureaucrat const &copy)
{
	if (this->_signGrade < copy.getGrade())
		throw Form::GradeTooLowException();

	if (this->_isSigned)
		throw std::invalid_argument("FormAlreadySigned");
    
	this->_isSigned = true;
}
Пример #15
0
void					test1(Bureaucrat &b, Form &f)
{
	std::cout << "\033[35mtest1: \033[0m" << std::endl;
	
	std::cout << b.getName() << "(" << b.getGrade() <<
		") trying to sign " << f.getName() << "(" << f.getSGrade() <<
		")" << std::endl;
	b.signForm(f);
	std::cout << std::endl;
	return ;
}
Пример #16
0
void            Form::beSigned( Bureaucrat const & b) {

    if (this->_signed == true) {
        std::cout << "form already signed" << std::endl;
        return;
        }
    if (b.getGrade() > this->_signGrade)
        throw GradeTooLowException("bureaucrat grade too low to sign the form");
    else
        this->_signed = true;
}
Пример #17
0
void		PresidentialPardonForm::execute( Bureaucrat const & executor ) const
{	
	if (this->getStatus() == 1)
	{
		if (executor.getGrade() <= this->getExecGrade())
			std::cout <<  this->getTarget() << " has been pardoned by Zafod Beeblebrox !" << std::endl;
		else
			throw Form::GradeTooLowException();	
	}
	else
		throw Form::NotSignedException();
}
Пример #18
0
/*------------------ Other -----------------*/
void				RobotomyRequestForm::execute(Bureaucrat const & executor) const {
	if (executor.getGrade() > 45)
		throw Form::GradeTooLowException();
	else if (this->getSigned())
	{
		int		rand = std::rand() % 2;

		if (rand == 0)
			std::cout << this->_target << " has been robotomized successfully" << std::endl;
		else
			std::cout << this->_target << " has been failure" << std::endl;
	}
}
void
ShrubberyCreationForm::execute(Bureaucrat const & f) const {
	if (this->getSign() == false)
		throw Form::FormIsNotSignedException();
	else if (this->getExecGrade() < f.getGrade())
		throw Form::GradeTooHighException();
	else {
		std::ofstream		ofs(this->_target + "_shrubbery");
		ofs << TREE << TREE << TREE << std::endl;
		ofs.close();
	}
	return ;
}
void			RobotomyRequestForm::execute(Bureaucrat const & executor) const
{
	if (executor.getGrade() > RobotomyRequestForm::_RobotomyExecute)
		throw Form::BureaucratNotClearForExecution();
	else
	{
		int fifty_fifty_chance = rand() % 2;

		std::cout << "* IIIHHHHH OOOOHHHH IIIIIIIH *\n";
		if (fifty_fifty_chance)
			std::cout << this->_target << " has been robotomized successfully\n";
		else
			std::cout << "Robotomized Form failed\n";
	}
}
Пример #21
0
/*
** public
*/
void					ShrubberyCreationForm::execute(Bureaucrat const &executor) const
{
	this->checkExec(executor.getGrade());

	std::ofstream   wStream(this->_target.c_str());

    if (!wStream)
    {
		std::cerr << "Error: could not open file." << std::endl;
        return ;
    }
	
	wStream << "This is a tiny ascii tree with two branches : Y" << std::endl
            << "Proof I'm not so lazzy, here another one : T" << std::endl;
}
Пример #22
0
void
RobotomyRequestForm::execute(Bureaucrat const & f) const {
	if (this->getSign() == false)
		throw Form::FormIsNotSignedException();
	else if (this->getExecGrade() < f.getGrade())
		throw Form::GradeTooHighException();
	else {
		std::cout << "* Drilling noises *" << std::endl;
		std::srand(std::time(0));
		int rand = std::rand();
		if (rand % 2)
			std::cout << this->_target << " has been robotomized successfully." << std::endl;
		else
			std::cout << this->_target << "'s robotomy is a failure." << std::endl;
	}
	return ;
}
Пример #23
0
void ShrubberyForm::execute(Bureaucrat const & p_bureaucrat) const
{
	Form::checkGradeToExec(p_bureaucrat.getGrade());
	std::string fileName = m_target + "_shrubbery";
	std::ofstream ofs;
	ofs.open(fileName.c_str());
	std::string tree =
	"       .#.\n"
	"      .###.\n"
	"     .#%##%.\n"
	"    .%##%###.\n"
	"   .##%###%##.\n"
	"  .#%###%##%##.\n"
	"        #\n"
	"        #\n";
	ofs << tree << tree;
	ofs.close();
}
Пример #24
0
bool	Form::beSigned(Bureaucrat const & bur)
{
	try
	{
		if (bur.getGrade() > this->_min_grade)
		{
			throw Form::GradeTooLowException();
			return (0);
		}
		else
		{
			this->_signed = 1;
			return (1);
		}
	}
	catch(Form::GradeTooLowException& e)
	{
		std::cout << e.what() << std::endl;
		return (0);
	}
	return (0);
}
Пример #25
0
/*------------------ Other -----------------*/
void				ShrubberyCreationForm::execute(Bureaucrat const & executor) const {
	if (this->getSigned())
		throw (Form::AlreadySignedException());
	else if (executor.getGrade() > 137)
		throw Form::GradeTooLowException();
	else
	{
		std::string		file = this->_target + "_shrubbery";
		std::ofstream	ofs;

		ofs.open(file);

		ofs << "       ###" << std::endl;
		ofs << "      #o###" << std::endl;
		ofs << "    #####o###" << std::endl;
		ofs << "   #o#\\#|#/###" << std::endl;
		ofs << "    ###\\|/#o#" << std::endl;
		ofs << "     # }|{  #" << std::endl;
		ofs << "       }|{" << std::endl;
		ofs.close();
	}
}
Пример #26
0
Bureaucrat::Bureaucrat(Bureaucrat &src) : name(src.getName()) {
    this->grade = src.getGrade();
}
Пример #27
0
Bureaucrat::Bureaucrat(Bureaucrat const &ref)
{
	this->setGrade(ref.getGrade());
	return ;
}
Пример #28
0
Bureaucrat::Bureaucrat(Bureaucrat const &src) : Name(src.getName()), Grade(src.getGrade()) {}
Пример #29
0
Bureaucrat::Bureaucrat( Bureaucrat const & cpy) : name(cpy.getName()), grade(cpy.getGrade())	{
	checkGrade();
}
Пример #30
0
/*------------------ Other -----------------*/
void			Form::beSigned(Bureaucrat const & b) {
	if (b.getGrade() > this->_gradeToSignIt)
		throw Form::GradeTooLowException();
	else
		this->_signed = true;
}