| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* Form.cpp :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: bchanot <bchanot@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2025/12/29 16:42:01 by bchanot #+# #+# */
- /* Updated: 2025/12/29 19:29:17 by bchanot ### ########.fr */
- /* */
- /* ************************************************************************** */
- #include "Form.hpp"
- #include "Bureaucrat.hpp"
- /*
- ** ------------------------------- CONSTRUCTOR --------------------------------
- */
- Form::Form() : _name("DefaultFormName"), _signGrade(1), _executeGrade(1), _signed(false)
- {
- }
- Form::Form( const std::string name, uint8_t execGrade, uint8_t signGrade ) : _name(name), _signGrade(signGrade), _executeGrade(execGrade), _signed(false)
- {
- if (this->_executeGrade > 150 || this->_signGrade > 150)
- throw Bureaucrat::GradeTooHighException();
- else if (this->_executeGrade < 1 || this->_signGrade < 1)
- throw Bureaucrat::GradeTooLowException();
- }
- Form::Form( const Form & src ) : _name(src._name), _signGrade(src._signGrade), _executeGrade(src._executeGrade), _signed(false)
- {
- if (this->_executeGrade > 150 || this->_signGrade > 150)
- throw Bureaucrat::GradeTooHighException();
- else if (this->_executeGrade < 1 || this->_signGrade < 1)
- throw Bureaucrat::GradeTooLowException();
- }
- /*
- ** -------------------------------- DESTRUCTOR --------------------------------
- */
- Form::~Form()
- {
- }
- /*
- ** --------------------------------- OVERLOAD ---------------------------------
- */
- Form & Form::operator=( Form const & rhs )
- {
- (void)rhs;
- //if ( this != &rhs )
- //{
- //this->_value = rhs.getValue();
- //}
- return *this;
- }
- std::ostream & operator<<( std::ostream & o, Form const & i )
- {
- o << "Form name : " << i.getName() << ", Minimum grade for sign : " << (int)i.getSignGrade() << ", Minimum exection grade : " << (int)i.getExecutionGrade() << ", Is signed : " << i.getSigned();
- return o;
- }
- /*
- ** --------------------------------- METHODS ----------------------------------
- */
- void Form::beSigned(const Bureaucrat &sch) {
- if (sch.getGrade() <= this->_signGrade)
- this->_signed = true;
- else
- throw Form::GradeTooLowException();
- }
- /*
- ** --------------------------------- ACCESSOR ---------------------------------
- */
- std::string const Form::getName(void) const {
- return this->_name;
- }
- uint8_t Form::getSignGrade(void) const {
- return this->_signGrade;
- }
- uint8_t Form::getExecutionGrade(void) const {
- return this->_executeGrade;
- }
- bool Form::getSigned(void) const {
- return this->_signed;
- }
- /* ************************************************************************** */
|