d05 ex02 ok pour Shrubbery form

This commit is contained in:
hugogogo
2022-03-04 20:58:15 +01:00
parent 130b228a2f
commit 0a5827f3a1
14 changed files with 297 additions and 194 deletions

View File

@@ -17,7 +17,8 @@ Bureaucrat::Bureaucrat( std::string name, int grade )
return;
}
Bureaucrat::Bureaucrat( Bureaucrat const & src ) {
Bureaucrat::Bureaucrat( Bureaucrat const & src )
: _name(src.getName()) {
std::cout << COPLIEN_COLOR "Bureaucrat copy constructor" RESET "\n";
*this = src;
return;
@@ -75,13 +76,31 @@ void Bureaucrat::gradeDown() {
throw GradeTooLowException();
}
void Bureaucrat::signForm( Form & f) {
void Bureaucrat::signForm( AForm & f) {
try {
f.beSigned( *this );
std::cout << _name << " signed " << f.getName() << "\n";
std::cout << _name << " signed "
<< f.getName() << "("
<< f.getTarget() << ")\n";
}
catch (std::exception & e) {
std::cout << _name << " couldn't sign " << f.getName()
<< f.getName() << "("
<< f.getTarget() << ")"
<< " because [" << e.what() << "]\n";
}
}
void Bureaucrat::executeForm( AForm const & f ) {
try {
f.execute( *this );
std::cout << _name << " executed "
<< f.getName() << "("
<< f.getTarget() << ")\n";
}
catch (std::exception & e) {
std::cout << _name << " couldn't execute "
<< f.getName() << "("
<< f.getTarget() << ")"
<< " because [" << e.what() << "]\n";
}
}