#include #include AForm::AForm() : name("Vente"), isSigned(false), gradeToSign(150), gradeToExecute(150) { std::cout << "AForm default constructor called" << std::endl; } AForm::AForm(const AForm& other) : name(other.name), isSigned(other.isSigned), gradeToSign(other.gradeToSign), gradeToExecute(other.gradeToExecute) { std::cout << "AForm copy constructor called" << std::endl; } AForm::AForm(const std::string& name) : name(name), isSigned(false), gradeToSign(150), gradeToExecute(150) { std::cout << "AForm (name) constructor called" << std::endl; } AForm::AForm(const std::string& name, const unsigned short gradeToSign, const unsigned short gradeToExecute) : name(name), isSigned(false), gradeToSign(gradeToSign), gradeToExecute(gradeToExecute) { std::cout << "AForm (name, gradeToSign, gradeToExecute) constructor called" << std::endl; if (gradeToSign > 150 || gradeToExecute > 150) throw GradeTooLowException(); if (gradeToSign < 1 || gradeToExecute < 1) throw GradeTooHighException(); } void AForm::beSigned(Bureaucrat& bureaucrat) { std::cout << "Be signed called" << std::endl; if (bureaucrat.getGrade() > gradeToSign) throw GradeTooLowException(); isSigned = true; } void AForm::execute(Bureaucrat const & executor) const { if (!isSigned) throw FormNotSignedException(); if (executor.getGrade() > gradeToExecute) throw GradeTooLowException(); executeAction(); } const std::string& AForm::getName() const { return name; } bool AForm::getIsSigned() const { return isSigned; } unsigned short AForm::getGradeToSign() const { return gradeToSign; } unsigned short AForm::getGradeToExecute() const { return gradeToExecute; } AForm& AForm::operator=(const AForm& other) { std::cout << "AForm assignment operator called" << std::endl; if (this != &other) isSigned = other.isSigned; return *this; } AForm::~AForm() { std::cout << "AForm destructor called" << std::endl; } const char* AForm::GradeTooHighException::what() const throw() { return "Grade too high"; } const char* AForm::GradeTooLowException::what() const throw() { return "Grade too low"; } const char* AForm::FormNotSignedException::what() const throw() { return "Form is not signed"; } std::ostream& operator<<(std::ostream& ostream, const AForm& form) { ostream << form.getName() << ", grade to sign " << form.getGradeToSign() << ", grade to execute " << form.getGradeToExecute() << "."; return ostream; }