Bureaucrat.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* Bureaucrat.hpp :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2025/12/26 17:51:13 by bchanot #+# #+# */
  9. /* Updated: 2025/12/29 16:31:34 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #ifndef BUREAUCRAT_HPP
  13. # define BUREAUCRAT_HPP
  14. # include <iostream>
  15. # include <string>
  16. # include <cstdint>
  17. class Bureaucrat
  18. {
  19. public:
  20. Bureaucrat();
  21. Bureaucrat( Bureaucrat const & src );
  22. Bureaucrat( std::string const name, u_int8_t grade );
  23. ~Bureaucrat();
  24. Bureaucrat &operator=( Bureaucrat const & rhs );
  25. Bureaucrat &operator++();
  26. Bureaucrat &operator--();
  27. class GradeTooHighException : public std::exception {
  28. public:
  29. virtual const char *what() const throw() {
  30. return ("The grade specified is too high !");
  31. }
  32. };
  33. class GradeTooLowException : public std::exception {
  34. public:
  35. virtual const char *what() const throw() {
  36. return ("The grade specified is too low !");
  37. }
  38. };
  39. uint8_t getGrade(void) const;
  40. std::string getName(void) const;
  41. void decrementGrade(void);
  42. void incrementGrade(void);
  43. private:
  44. std::string _name;
  45. uint8_t _grade;
  46. };
  47. std::ostream & operator<<( std::ostream & o, Bureaucrat const & i );
  48. #endif /* ****************************************************** BUREAUCRAT_H */