File tree 2 files changed +7
-4
lines changed
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ class Bureaucrat {
17
17
const std::string _name;
18
18
int _grade;
19
19
20
+ static const int _minGrade = 150 ;
21
+ static const int _maxGrade = 1 ;
22
+
20
23
public:
21
24
class GradeTooHighException : public std ::exception {
22
25
public:
Original file line number Diff line number Diff line change 7
7
Bureaucrat::Bureaucrat () : _name(" not set" ), _grade(0 ) {}
8
8
9
9
Bureaucrat::Bureaucrat (const std::string &name, int grade) : _name(name) {
10
- if (grade > 150 )
10
+ if (grade > _minGrade )
11
11
throw GradeTooHighException ();
12
- else if (grade < 1 )
12
+ else if (grade < _maxGrade )
13
13
throw GradeTooHighException ();
14
14
_grade = grade;
15
15
}
@@ -51,15 +51,15 @@ void Bureaucrat::executeForm(AForm const &form) {
51
51
}
52
52
53
53
void Bureaucrat::incrementGrade () {
54
- if (this ->_grade > 1 ) {
54
+ if (this ->_grade > _maxGrade ) {
55
55
this ->_grade --;
56
56
} else {
57
57
throw GradeTooHighException ();
58
58
}
59
59
}
60
60
61
61
void Bureaucrat::decrementGrade () {
62
- if (this ->_grade < 150 ) {
62
+ if (this ->_grade < _minGrade ) {
63
63
this ->_grade ++;
64
64
} else {
65
65
throw GradeTooLowException ();
You can’t perform that action at this time.
0 commit comments