feat: adding files made in fablab

This commit is contained in:
Raphael 2025-03-19 16:11:05 +01:00
parent 9067bf46fc
commit 5d81e1e176
17 changed files with 885 additions and 12 deletions

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/16 14:49:52 by rparodi #+# #+# */
/* Updated: 2025/03/17 21:45:02 by rparodi ### ########.fr */
/* Updated: 2025/03/18 11:43:49 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -114,7 +114,7 @@ std::ostream& operator<<(std::ostream& output, Bureaucrat const &toPrint) {
return (output);
}
void Bureaucrat::signForm(Form &form) {
void Bureaucrat::signForm(Form const &form) {
try {
form.beSigned(*this);
} catch (std::exception &e) {

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/16 14:48:33 by rparodi #+# #+# */
/* Updated: 2025/03/17 22:00:20 by rparodi ### ########.fr */
/* Updated: 2025/03/18 11:44:02 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -33,7 +33,7 @@ class Bureaucrat {
int getGrade(void) const;
void promote(void);
void demote(void);
void signForm(Form &form);
void signForm(Form const &form);
class GradeTooHighException : public std::exception {
virtual const char *what() const throw() {
return ("Error:\n> Grade is too high (have to be lower than 1)");

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/17 14:19:41 by rparodi #+# #+# */
/* Updated: 2025/03/18 09:42:55 by rparodi ### ########.fr */
/* Updated: 2025/03/18 11:44:31 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -79,14 +79,14 @@ std::ostream& operator<<(std::ostream& output, Form const &toPrint) {
return (output);
}
void Form::beSigned(Bureaucrat &bureaucrat) {
void Form::beSigned(Bureaucrat const &bureaucrat) const {
if (bureaucrat.getGrade() > this->_to_sign) {
throw FormForSupperior();
} else if (_signed == true) {
throw FormAlreadySigned();
}
else {
std::cout << "Bureaucrat " << bureaucrat.getName() << " signs the form " << this->_name << std::endl;
std::cout << "Bureaucrat " << bureaucrat.getName() << " signs the Form " << this->_name << std::endl;
this->_signed = true;
}
}

View file

@ -6,12 +6,12 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/17 14:20:06 by rparodi #+# #+# */
/* Updated: 2025/03/17 22:00:37 by rparodi ### ########.fr */
/* Updated: 2025/03/18 11:49:04 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FORM_HPP
#define FORM_HPP
#ifndef Form_HPP
#define Form_HPP
#include <string>
#include <iostream>
@ -48,13 +48,13 @@ class Form {
};
std::string getName() const;
void beSigned(Bureaucrat &bureaucrat);
void beSigned(Bureaucrat const &bureaucrat) const;
int getExecute() const;
int getSign() const;
bool isSigned() const;
private:
std::string _name;
bool _signed;
mutable bool _signed;
int _to_execute;
int _to_sign;
};