diff --git a/cpp05/ex00/Bureaucrat.cpp b/cpp05/ex00/Bureaucrat.cpp index d097695..c920015 100644 --- a/cpp05/ex00/Bureaucrat.cpp +++ b/cpp05/ex00/Bureaucrat.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/16 14:49:52 by rparodi #+# #+# */ -/* Updated: 2025/03/16 22:00:36 by rparodi ### ########.fr */ +/* Updated: 2025/03/16 22:16:30 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,7 +27,7 @@ Bureaucrat::Bureaucrat(void) : _name("Roger"), _grade(150) { * @param name the name of the Bureaucrat * @param grade grade to start the carreer */ -Bureaucrat::Bureaucrat(std::string name, u_int8_t grade) : _name(name) { +Bureaucrat::Bureaucrat(std::string name, int grade) : _name(name) { std::cout << "[Bureaucrat] Smart constructor called" << std::endl; if (grade < 1) { throw GradeTooHighException(); @@ -68,7 +68,7 @@ Bureaucrat::~Bureaucrat() { * * @return grade (unsigned int 8bits) */ -u_int8_t Bureaucrat::getGrade() const { +int Bureaucrat::getGrade() const { return (this->_grade); } diff --git a/cpp05/ex00/Bureaucrat.hpp b/cpp05/ex00/Bureaucrat.hpp index 19b77e5..64e2216 100644 --- a/cpp05/ex00/Bureaucrat.hpp +++ b/cpp05/ex00/Bureaucrat.hpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/16 14:48:33 by rparodi #+# #+# */ -/* Updated: 2025/03/16 22:01:02 by rparodi ### ########.fr */ +/* Updated: 2025/03/16 22:16:36 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,15 +16,21 @@ #include #include +#define RESET "\033[0m" +#define YELLOW "\033[0;33m" +#define RED "\033[0;31m" + class Bureaucrat { public: Bureaucrat(void); - Bureaucrat(std::string name, u_int8_t grade); + Bureaucrat(std::string name, int grade); Bureaucrat(Bureaucrat const ©); Bureaucrat& operator=(Bureaucrat const &assign); ~Bureaucrat(void); std::string getName(void) const; - u_int8_t getGrade(void) const; + int getGrade(void) const; + void promote(void); + void demote(void); class GradeTooHighException : public std::exception { virtual const char *what() const throw() { return ("Error:\n> Grade is too high (have to be lower than 1)"); @@ -37,7 +43,7 @@ class Bureaucrat { }; private: std::string _name; - u_int8_t _grade; + int _grade; }; std::ostream& operator<<(std::ostream& os, Bureaucrat const &bureaucrat); diff --git a/cpp05/ex00/Makefile b/cpp05/ex00/Makefile index a604c96..f5310c1 100644 --- a/cpp05/ex00/Makefile +++ b/cpp05/ex00/Makefile @@ -22,7 +22,9 @@ RM = rm -rf # Mandatory flags for 42 CXXFLAGS = -Werror -Wextra -Wall -std=c++98 -I./includes/ # Flags to debug and have the dependences (can be removed for correction) -CXXFLAGS += -MMD -g3 +CXXFLAGS += -MMD + +DEBUG += -g3 -fsanitize=address # Sources SRC = Bureaucrat.cpp \