Skip to content

Commit 79346ed

Browse files
committed
fix bureaucrat
1 parent b2aa945 commit 79346ed

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

module_05/ex02/include/Bureaucrat.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class Bureaucrat {
1717
const std::string _name;
1818
int _grade;
1919

20+
static const int _minGrade = 150;
21+
static const int _maxGrade = 1;
22+
2023
public:
2124
class GradeTooHighException : public std::exception {
2225
public:

module_05/ex02/src/Bureaucrat.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
Bureaucrat::Bureaucrat() : _name("not set"), _grade(0) {}
88

99
Bureaucrat::Bureaucrat(const std::string &name, int grade) : _name(name) {
10-
if (grade > 150)
10+
if (grade > _minGrade)
1111
throw GradeTooHighException();
12-
else if (grade < 1)
12+
else if (grade < _maxGrade)
1313
throw GradeTooHighException();
1414
_grade = grade;
1515
}
@@ -51,15 +51,15 @@ void Bureaucrat::executeForm(AForm const &form) {
5151
}
5252

5353
void Bureaucrat::incrementGrade() {
54-
if (this->_grade > 1) {
54+
if (this->_grade > _maxGrade) {
5555
this->_grade--;
5656
} else {
5757
throw GradeTooHighException();
5858
}
5959
}
6060

6161
void Bureaucrat::decrementGrade() {
62-
if (this->_grade < 150) {
62+
if (this->_grade < _minGrade) {
6363
this->_grade++;
6464
} else {
6565
throw GradeTooLowException();

0 commit comments

Comments
 (0)