29Bureaucrat::Bureaucrat(
const std::string &name,
int grade) : _name(name) {
37 std::cout <<
"Bureaucrat " << this->_name <<
" created with grade " << this->_grade <<
"." <<
std::endl;
44Bureaucrat::Bureaucrat(
const Bureaucrat &other) : _name(other._name), _grade(other._grade) {
56 this->_grade = other._grade;
58 std::cout <<
"Bureaucrat " << this->_name <<
"'s grade has been assigned from " << other._name <<
"." <<
std::endl;
88 if (this->_grade - 1 < 1) {
92 std::cout <<
"Bureaucrat " << this->_name <<
" grade incremented to " << this->_grade <<
"." <<
std::endl;
100 if (this->_grade + 1 > 150) {
104 std::cout <<
"Bureaucrat " << this->_name <<
" grade decremented to " << this->_grade <<
"." <<
std::endl;
114 return "Bureaucrat Error: Grade is too high (must be >= 1)";
122 return "Bureaucrat Error: Grade is too low (must be <= 150)";
134 os << bureaucrat.
getName() <<
", bureaucrat grade " << bureaucrat.
getGrade() <<
".";
virtual const char * what() const
Represents a bureaucrat with a name and a grade.
void incrementGrade()
Increments the bureaucrat's grade (e.g., from 3 to 2).
void decrementGrade()
Decrements the bureaucrat's grade (e.g., from 2 to 3).
int getGrade() const
Gets the grade of the Bureaucrat.
~Bureaucrat()
Destroy the Bureaucrat:: Bureaucrat object
Bureaucrat & operator=(const Bureaucrat &other)
Assignment operator for Bureaucrat.
const std::string & getName() const
Gets the name of the Bureaucrat.
Defines the Bureaucrat class, updated to execute AForms.
std::ostream & operator<<(std::ostream &os, const Bureaucrat &bureaucrat)
Overloads the << operator to print Bureaucrat information.