예제 #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;
	}
}
예제 #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;
	}
}
예제 #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;
	}
}
예제 #4
0
파일: Bureaucrat.cpp 프로젝트: NegMozzie/42
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;
    }
}
예제 #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;
}
예제 #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 ;
}
예제 #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;
    }
}
예제 #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;
	}
}