From f47dd976dbdd8dc9120a222d7676391bad5af2b9 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sun, 16 Mar 2025 22:20:48 +0100 Subject: [PATCH] feat: adding the method demote / promote --- cpp05/ex00/Bureaucrat.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cpp05/ex00/Bureaucrat.cpp b/cpp05/ex00/Bureaucrat.cpp index c920015..4e822df 100644 --- a/cpp05/ex00/Bureaucrat.cpp +++ b/cpp05/ex00/Bureaucrat.cpp @@ -81,6 +81,27 @@ std::string Bureaucrat::getName() const { 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 *