feat: adding the method demote / promote

This commit is contained in:
Raphael 2025-03-16 22:20:48 +01:00
parent 0e3f3a6e3b
commit f47dd976db

View file

@ -81,6 +81,27 @@ std::string Bureaucrat::getName() const {
return (this->_name); return (this->_name);
} }
/**
* @brief Get a promotion for the Bureaucrat
*/
void Bureaucrat::promote() {
if (this->_grade == 1) {
throw GradeTooHighException();
} else {
--this->_grade;
}
}
/**
* @brief Get a demotion for the Bureaucrat
*/
void Bureaucrat::demote() {
if (this->_grade == 150) {
throw GradeTooLowException();
} else {
++this->_grade;
}
}
/** /**
* @brief Overload of the '<<' operator to print * @brief Overload of the '<<' operator to print
* *