void Form::beSigned( Bureaucrat & bureau ) { if (bureau.getGrade() > this->_sign_grade ) throw Form::GradeTooLowException(); else this->_status = true; }
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"; }
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); }
void Form::execute(Bureaucrat const & executor) const { if (!this->getSigned() || executor.getGrade() > this->getExeGrade()) throw Form::GradeTooLowException(); else { this->action(); } }
void Form::beSigned(Bureaucrat & p_bureaucrat) { if (p_bureaucrat.getGrade() <= mn_gradeToSign) mb_isSigned = true; else throw Form::GradeTooLowException(); }
void Form::beSigned(Bureaucrat& b) { if (b.getGrade() <= m_sgrade) m_sign = 1; else throw GradeTooLowException(); return; }
void Form::execute(const Bureaucrat& executor) const { if (executor.getGrade() > _grade_to_execute) { throw Form::GradeTooLowException(); } else if (!_is_signed) { throw Form::NotSignedException(); } }
void Form::execute(Bureaucrat const &b) const throw(GradeTooLowException) { if (b.getGrade() <= gradeExec && sign) action(); else throw GradeTooLowException(); }
void Form::beSigned(Bureaucrat &src) { if (src.getGrade() <= this->gradeSign) { this->validated = true; } else { throw GradeTooLowException(); } }
void Form::beSigned(Bureaucrat& b) { if (b.getGrade() < _grade_to_sign) { _is_signed = true; } else { throw Form::GradeTooLowException(); } }
void Form::beSigned(Bureaucrat const &b) throw(GradeTooLowException) { if (b.getGrade() <= gradeSign) sign = true; else throw GradeTooLowException(); }
void Form::beSigned(Bureaucrat & bureaucrat) { if (bureaucrat.getGrade() > _gradeSign) // Si le bureaucrat ne peut pas sign form { throw Form::GradeTooLowException(); } else _isSigned = true; }
void Form::beSigned(Bureaucrat const ©) { if (this->_signGrade < copy.getGrade()) throw Form::GradeTooLowException(); if (this->_isSigned) throw std::invalid_argument("FormAlreadySigned"); this->_isSigned = true; }
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 ; }
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; }
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(); }
/*------------------ 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"; } }
/* ** 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; }
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 ; }
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(); }
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); }
/*------------------ 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(); } }
Bureaucrat::Bureaucrat(Bureaucrat &src) : name(src.getName()) { this->grade = src.getGrade(); }
Bureaucrat::Bureaucrat(Bureaucrat const &ref) { this->setGrade(ref.getGrade()); return ; }
Bureaucrat::Bureaucrat(Bureaucrat const &src) : Name(src.getName()), Grade(src.getGrade()) {}
Bureaucrat::Bureaucrat( Bureaucrat const & cpy) : name(cpy.getName()), grade(cpy.getGrade()) { checkGrade(); }
/*------------------ Other -----------------*/ void Form::beSigned(Bureaucrat const & b) { if (b.getGrade() > this->_gradeToSignIt) throw Form::GradeTooLowException(); else this->_signed = true; }