예제 #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::signForm( Form & form ) const {
	try {
		form.beSigned(*this);
		std::cout << _name << "signs form [" << form.getName() << "]" << std::endl;
	} catch (Form::GradeTooLowException & e) {
		std::cout << _name << " cannot sign form [" << form.getName() << "] because";
		std::cout << " " << e.what() << std::endl;
	}
}
예제 #3
0
void Bureaucrat::signForm(Form & form)
{
	try {
		form.beSigned(*this);
		std::cout << this->_name << " signs " << form.getName() << std::endl;
	} catch (std::exception &e) {
		std::cout << this->_name << " cannot sign " << form.getName() << " because " << e.what() << std::endl;
	}
}
예제 #4
0
파일: Bureaucrat.cpp 프로젝트: NegMozzie/42
void Bureaucrat::signForm(Form &src) {

    src.beSigned(*this);
    if (src.getGradeSign() >= this->getGrade()) {
        std::cout << "<" << this->name << "> signs " << src.getName() << std::endl;
    }
    else {
        std::cout << "<" << this->name << "> cannot signs " << src.getName() << " because " << "the form grade is too low" << std::endl;
    }
}
예제 #5
0
void
Bureaucrat::signForm(Form & f) {
	if (this->_grade > f.getSignGrade()) {
		std::cout << this->_name << " cannot sign because "; 
		throw Bureaucrat::GradeTooLowException();
	}
	else {
		f.beSigned(*this);
		std::cout << this->_name << " signs " << f.getName() << std::endl;
	}
	return;
}
예제 #6
0
void	Bureaucrat::signForm(Form &form)
{
	try 
	{
		form.beSigned(this);
		std::cout << this->_name << " signs " << form.getName() << std::endl;
	}
	catch (std::exception &e)
	{
		std::cout << this->_name << " cannot sign " << form.getName() << " because his grade isn't high enough" << std::endl;
	}
}
예제 #7
0
void				Bureaucrat::signForm(Form & f) {
	try
	{
		f.beSigned(*this);
		std::cout << this->_name << " signs " << f.getName() << std::endl;

	}
	catch (Form::GradeTooLowException & e)
	{
		std::cout << this->_name << " cannot sign " << f.getName() << " because He's low grade" << std::endl;
	}

}
예제 #8
0
void		Bureaucrat::signForm(Form &form)
{
	try
	{
		if (form.beSigned(*this))
			std::cout << this->_name << " signs " << form.getName() << std::endl;
	}
	catch (std::exception const &err)
	{
		std::cout << this->_name << " cannot sign " << form.getName();
		std::cout << " because " << err.what() << std::endl;
    }
	return ;
}
예제 #9
0
void		Bureaucrat::signForm(Form& f) const
{
	try
	{
		f.beSigned((Bureaucrat&)*this);
	}
	catch (Form::GradeTooLowException &e)
	{
		std::cout << m_name << " " << " cannot sign " << f << " because " << e.what() << std::endl;
		return;
	}
	std::cout << m_name << " " << " signs " << f << std::endl;
	return;
}
예제 #10
0
void		Bureaucrat::signForm(Form & con)
{
	if (con.beSigned(*this))
	{
		std::cout << this->_name << " signs " << con.getName() << "." << std::endl;
	}
	else if (!con.getSigned())
	{
		std::cout << this->_name << " cannot sign " << con.getName() << " because his level is too low." << std::endl;
	}
	else
	{
		std::cout << this->_name << " cannot sign " << con.getName() << " because the form is already signed." << std::endl;
	}

}
예제 #11
0
void				Bureaucrat::signForm( Form & form ) const {
	try {
		bool	wasSigned = form.getWasSigned();

		form.beSigned(*this);
		std::cout << "Bureaucrat " << name << " (Grade " << grade << ") signs a " << form.getName()
		<< " (s.grade " << form.getRequirementSign() << ", ex.grade " << form.getRequirementExec()
		<< ")";
		if (wasSigned)
			std::cout << " (Signed)." << std::endl;
		else
			std::cout << " (Unsigned)." << std::endl;
		
	} catch (Form::GradeTooLowException) {
		std::cout << "Bureaucrat " << name << " cannot sign " << form.getName() << " because his grade is too low (His grade is "
			<< grade << " but should be at least " << form.getRequirementSign() << ")." << std::endl;
	} catch (std::exception) {
		std::cout << "Bureaucrat " << name << " cannot sign " << form.getName() << " because of an unknown reason." << std::endl;
	}
}