From d0a2146252d43c0a745e156d82a9ababe4b9aa1c Mon Sep 17 00:00:00 2001 From: aortigos Date: Tue, 17 Feb 2026 09:50:40 +0100 Subject: [PATCH] Adding comments --- ex00/Bureaucrat/Bureaucrat.cpp | 42 ++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/ex00/Bureaucrat/Bureaucrat.cpp b/ex00/Bureaucrat/Bureaucrat.cpp index 5c11c68..6c46888 100644 --- a/ex00/Bureaucrat/Bureaucrat.cpp +++ b/ex00/Bureaucrat/Bureaucrat.cpp @@ -12,6 +12,10 @@ #include "Bureaucrat.hpp" +////////////////// +//Constructores // +////////////////// + Bureaucrat::Bureaucrat() : name("NULL"), grade(150) { //std::cout << "Bureaucrat has been created" << std::endl; @@ -45,6 +49,11 @@ Bureaucrat::Bureaucrat(std::string name, int grade) : name(name) //std::cout << "Bureaucrat with params has been created" << std::endl; } + +////////////////// +// Getters // +////////////////// + std::string Bureaucrat::getName() const { return (this->name); @@ -55,6 +64,11 @@ int Bureaucrat::getGrade() const return (this->grade); } + +////////////////// +// Grade // +////////////////// + void Bureaucrat::incrementGrade() { if (this->grade <= 1) @@ -69,6 +83,25 @@ void Bureaucrat::decrementGrade() this->grade++; } + +////////////////// +// << // +////////////////// + +std::ostream &operator<<(std::ostream &os, const Bureaucrat &bureaucrat) +{ + os << bureaucrat.getName() + << ", bureaucrat grade " + << bureaucrat.getGrade() + << std::endl; + return (os); +} + + +////////////////// +// Excepciones // +////////////////// + const char* Bureaucrat::GradeTooHighException::what() const throw() { return ("Grade is too high!"); @@ -78,12 +111,3 @@ const char* Bureaucrat::GradeTooLowException::what() const throw() { return ("Grade is too low!"); } - -std::ostream &operator<<(std::ostream &os, const Bureaucrat &bureaucrat) -{ - os << bureaucrat.getName() - << ", bureaucrat grade " - << bureaucrat.getGrade() - << std::endl; - return (os); -} \ No newline at end of file