Exemple #1
0
void	OfficeBlock::doBureaucracy(const std::string& form_name, const std::string& target) const
{
	if (this->_intern && this->_b_sign && this->_b_exec)
	{
		Form 	*f = this->_intern->makeForm(form_name, target);
		if (f)
		{
			std::cout << "Intern make a form of type \"" << form_name << "\": " << *f;
			f->beSigned(*this->_b_sign);
			std::cout << "Bureaucrat " << this->_b_sign->getName() << " signed the form " << f->getName() << std::endl;
			f->execute(*this->_b_exec);
			std::cout << "Bureaucrat " << this->_b_exec->getName() << " execute the form " << f->getName() << std::endl;
			delete f;
		} else {
			std::cerr << "Intern can't make a Form of type \"" << form_name << "\"" << std::endl;
		}
	} else {
		if (!this->_intern)
			std::cerr << "An Intern is required in OfficeBlock" << std::endl;
		if (!this->_b_sign)
			std::cerr << "An Bureaucrat is required in OfficeBlock to sign the form" << std::endl;
		if (!this->_b_exec)
			std::cerr << "An Bureaucrat is required in OfficeBlock to execute the form" << std::endl;
	}
}
Exemple #2
0
void				Bureaucrat::executeForm(Form & form) const {
	try {
		form.execute(*this);
		std::cout << _name << " executes " << form.getName() << std::endl;
	} catch (std::exception & e) {
		std::cout << _name << " cannot execute " << form.getName();
		std::cout << " because " << e.what() << std::endl;
	}
}
Exemple #3
0
void Bureaucrat::executeForm(Form const & form)
{
	try {
		form.execute(*this);
		std::cout << this->_name << " executes " << form.getName() << std::endl;
	} catch (std::exception & e) {
		std::cout << this->_name << " can't execute " << form.getName() << " : " << e.what() << std::endl;
	}
}
Exemple #4
0
void Bureaucrat::executeForm(Form const &form) {
    try {
        form.execute(*this);
        std::cout << "<bureaucrat> executes <" << form.getName() << ">" << std::endl;

    }
    catch (std::exception &e) {
        std::cout << e.what() << std::endl;
    }
}
Exemple #5
0
bool Bureaucrat::executeForm(Form const & form)
{
	try {
		form.execute(*this);
		return true;
	} catch (std::exception & e) {
		std::cout << this->_name << " can't execute " << form.getName() << " : " << e.what() << std::endl;
	}
	return false;
}
Exemple #6
0
void
Bureaucrat::executeForm(Form const & f) {
	try {
		f.execute(*this);
		std::cout << this->_name << " executes " << f.getName() << "." << std::endl;
	}
	catch (std::exception & e) {
		std::cout << e.what() << std::endl;
	}
	return ;
}
Exemple #7
0
void				Bureaucrat::executeForm(Form const & form) {
	try
	{
		form.execute(*this);
		std::cout << this->_name << " executes " << form.getName() << std::endl;
	}
    catch (Form::GradeTooLowException & e)
    {
        std::cout << e.errorGrade() << " for " << form.getName() << std::endl;
    }
    catch (Form::AlreadySignedException & e)
    {
        std::cout << e.errorSigned() << " for " << form.getName() << std::endl;
    }
}
Exemple #8
0
void		Bureaucrat::executeForm( Form const & form ) const
{
	try
	{
		form.execute(*this);
		std::cout << this->getName() << " executes " << form.getName() << std::endl;
	}
	catch (Form::GradeTooLowException & e)
	{
		std::cout << this->getName() << " can't executes " << form.getName() << "cause his grade is " << this->getGrade() << " and need to be " << form.getExecGrade() << std::endl;
	}
	catch (Form::NotSignedException & e)
	{
		std::cout << this->getName() << " can't executes " << form.getName() << " cause the form " << form.getName() << " is not signed !" << std::endl;
	}
}