Form.hpp
1 /* ************************************************************************** */ 2 /* */ 3 /* ::: :::::::: */ 4 /* Form.hpp :+: :+: :+: */ 5 /* +:+ +:+ +:+ */ 6 /* By: gychoi <gychoi@student.42seoul.kr> +#+ +:+ +#+ */ 7 /* +#+#+#+#+#+ +#+ */ 8 /* Created: 2023/11/27 16:23:50 by gychoi #+# #+# */ 9 /* Updated: 2023/11/28 16:46:31 by gychoi ### ########.fr */ 10 /* */ 11 /* ************************************************************************** */ 12 13 #pragma once 14 #ifndef __FORM_HPP__ 15 #define __FORM_HPP__ 16 17 #include <iostream> 18 #include <stdexcept> 19 #include <string> 20 21 #include "Bureaucrat.hpp" 22 23 /* ************************************************************************** */ 24 /* Form */ 25 /* ************************************************************************** */ 26 class Form 27 { 28 public: 29 Form(); 30 Form(std::string const& name, int signGrade, int executeGrade); 31 Form(Form const& target); 32 Form& operator=(Form const& target); 33 ~Form(); 34 35 public: 36 std::string const& getName() const; 37 bool getIsSigned() const; 38 int getSignGrade() const; 39 int getExecuteGrade() const; 40 void setIsSigned(bool isSigned); 41 42 public: 43 void beSigned(Bureaucrat const& bureaucrat); 44 45 private: 46 std::string const mName; 47 bool mbIsSigned; 48 int const mSignGrade; 49 int const mExecuteGrade; 50 51 /* ************************************************************************** */ 52 /* Form::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 /* Form::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, Form const& target); 99 100 #endif /* __FORM_HPP__ */