#include "Bureaucrat.hpp" Bureaucrat::Bureaucrat() : name("") { this->grade = 150; } Bureaucrat::Bureaucrat(std::string name, int grade) :name(name){ if (grade > 150) throw Bureaucrat::GradeTooLowException(); else if (grade < 1) throw Bureaucrat::GradeTooHighException(); this->grade = grade; } Bureaucrat::~Bureaucrat() { } Bureaucrat::Bureaucrat(const Bureaucrat &other) : name(other.name) { *this = other; } Bureaucrat &Bureaucrat::operator=(const Bureaucrat &other) { if (this != &other) { this->grade = other.grade; } return (*this); } std::string Bureaucrat::getName() const { return this->name; } int Bureaucrat::getGrade() const { return this->grade; } void Bureaucrat::increaseGrade() { if (this->grade <= 1) throw Bureaucrat::GradeTooHighException(); this->grade--; } void Bureaucrat::decreaseGrade() { if (this->grade >= 150) throw Bureaucrat::GradeTooLowException(); this->grade++; } std::ostream& operator<<( std::ostream& os, Bureaucrat const& crat ) { return os << crat.getName() << ", bureaucrat grade " << crat.getGrade() << "." << std::endl; } char const* Bureaucrat::GradeTooHighException::what() const throw() { return "Grade is too high"; } char const* Bureaucrat::GradeTooLowException::what() const throw() { return "Grade is too low"; }