feat: adding the method demote / promote
This commit is contained in:
parent
0e3f3a6e3b
commit
f47dd976db
1 changed files with 21 additions and 0 deletions
|
|
@ -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
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue