1
0

🏗️」 wip: Started ex01

This commit is contained in:
2025-03-29 16:49:28 +01:00
parent 6bc8d232e9
commit 0e7e6d87b2
6 changed files with 390 additions and 0 deletions

49
ex01/Form.cpp Normal file
View File

@ -0,0 +1,49 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Form.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/09 17:38:19 by adjoly #+# #+# */
/* Updated: 2025/03/29 16:49:11 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "Form.hpp"
#include "Bureaucrat.hpp"
Form::Form(void) : _name(""), _signed(false), _minForExec(1), _minForSign(1) {
_log("", "Form", "", "default constructor called");
}
Form::Form(std::string name, uint8_t minForSign, uint8_t minForExec)
: _name(name), _signed(false), _minForSign(minForSign),
_minForExec(minForExec) {
_log("", "Form", "", "default constructor called");
}
Form::~Form(void) { _log("", "Form", "", "destructor called"); }
const char *Form::GradeTooHighException::what() const throw() {
return ("Grade is too high");
}
const char *Form::GradeTooLowException::what() const throw() {
return ("Grade is too low");
}
const std::string Form::getName(void) const { return _name; }
bool Form::getSigned(void) { return _signed; }
const uint8_t Form::getMinForSign(void) { return _minForSign; }
const uint8_t Form::getMinForExec(void) { return _minForExec; }
void Form::beSigned(Bureaucrat b) {
if (_minForSign > b.getGrade()) {
throw GradeTooLowException();
}
_signed = true;
}
std::ostream &operator<<(std::ostream &os, Form &val) {
os << "Form: " << val.getName() << ", minGrade to sign: " <<
}