Bureaucrat.hpp
1 /* ************************************************************************** */ 2 /* */ 3 /* ::: :::::::: */ 4 /* Bureaucrat.hpp :+: :+: :+: */ 5 /* +:+ +:+ +:+ */ 6 /* By: gychoi <gychoi@student.42seoul.kr> +#+ +:+ +#+ */ 7 /* +#+#+#+#+#+ +#+ */ 8 /* Created: 2023/11/09 23:13:08 by gychoi #+# #+# */ 9 /* Updated: 2023/11/29 22:27:46 by gychoi ### ########.fr */ 10 /* */ 11 /* ************************************************************************** */ 12 13 #pragma once 14 #ifndef __BUREAUCRAT_HPP__ 15 #define __BUREAUCRAT_HPP__ 16 17 #include <iostream> 18 #include <stdexcept> 19 #include <string> 20 21 class AForm; 22 23 /* ************************************************************************** */ 24 /* Bureaucrat */ 25 /* ************************************************************************** */ 26 class Bureaucrat 27 { 28 public: 29 Bureaucrat(); 30 Bureaucrat(std::string const& name, int grade); 31 Bureaucrat(Bureaucrat const& target); 32 Bureaucrat& operator=(Bureaucrat const& target); 33 ~Bureaucrat(); 34 35 public: 36 std::string const& getName() const; 37 int getGrade() const; 38 void setGrade(int grade); 39 40 public: 41 void increaseGrade(); 42 void decreaseGrade(); 43 void signForm(AForm& form); 44 void executeForm(AForm const& form); 45 46 47 private: 48 std::string const mName; 49 int mGrade; 50 51 /* ************************************************************************** */ 52 /* Bureaucrat::GradeTooHighException */ 53 /* ************************************************************************** */ 54 public: 55 class GradeTooHighException : public std::exception 56 { 57 public: 58 GradeTooHighException(); 59 GradeTooHighException(std::string const& msg); 60 GradeTooHighException(GradeTooHighException const& target); 61 GradeTooHighException& operator=(GradeTooHighException const& target); 62 virtual ~GradeTooHighException() throw(); 63 64 public: 65 std::string const& getMessage() const; 66 67 public: 68 virtual char const* what() const throw(); 69 70 private: 71 std::string mMessage; 72 }; 73 74 /* ************************************************************************** */ 75 /* Bureaucrat::GradeTooLowException */ 76 /* ************************************************************************** */ 77 public: 78 class GradeTooLowException : public std::exception 79 { 80 public: 81 GradeTooLowException(); 82 GradeTooLowException(std::string const& msg); 83 GradeTooLowException(GradeTooLowException const& target); 84 GradeTooLowException& operator=(GradeTooLowException const& target); 85 virtual ~GradeTooLowException() throw(); 86 87 public: 88 std::string const& getMessage() const; 89 90 public: 91 virtual char const* what() const throw(); 92 93 private: 94 std::string mMessage; 95 }; 96 }; 97 98 std::ostream& operator<<(std::ostream& os, Bureaucrat const& target); 99 100 #endif /* __BUREAUCRAT_HPP__ */