From 2b136d90f4dc951f17950b4ada9bc991e03e5569 Mon Sep 17 00:00:00 2001 From: adjoly Date: Sun, 30 Mar 2025 16:18:58 +0200 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=E2=9C=A8=E3=80=8D=20feat:=20finished?= =?UTF-8?q?=20ex01=20(normally)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ex01/Bureaucrat.cpp | 7 ++++--- ex01/Bureaucrat.hpp | 2 +- ex01/Form.cpp | 19 ++++++++++--------- ex01/Form.hpp | 15 ++++++++------- ex01/Makefile | 4 ++-- ex01/main.cpp | 4 ++-- 6 files changed, 27 insertions(+), 24 deletions(-) diff --git a/ex01/Bureaucrat.cpp b/ex01/Bureaucrat.cpp index e4248b1..db2b89c 100644 --- a/ex01/Bureaucrat.cpp +++ b/ex01/Bureaucrat.cpp @@ -6,11 +6,12 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/23 13:59:45 by adjoly #+# #+# */ -/* Updated: 2025/03/29 16:49:20 by adjoly ### ########.fr */ +/* Updated: 2025/03/30 15:13:43 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #include "Bureaucrat.hpp" +#include "Form.hpp" #include void _log(std::string emoji, std::string what, std::string who, @@ -102,9 +103,9 @@ const char *Bureaucrat::GradeTooLowException::what() const throw() { void Bureaucrat::signForm(Form &f) { try { - f.getSigned(); + f.beSigned(*this); std::cout << _name << " signed " << f.getName() << std::endl; } catch (std::exception &e) { - std::cout << _name << "counldn't sign " << f.getName() << " because " << e.what() << std::endl; + std::cout << _name << " counldn't sign " << f.getName() << " because " << e.what() << std::endl; } } diff --git a/ex01/Bureaucrat.hpp b/ex01/Bureaucrat.hpp index 78196a7..65eb429 100644 --- a/ex01/Bureaucrat.hpp +++ b/ex01/Bureaucrat.hpp @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/23 13:59:43 by adjoly #+# #+# */ -/* Updated: 2025/03/29 15:42:43 by adjoly ### ########.fr */ +/* Updated: 2025/03/30 15:10:46 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/ex01/Form.cpp b/ex01/Form.cpp index f4153da..28b50c8 100644 --- a/ex01/Form.cpp +++ b/ex01/Form.cpp @@ -6,14 +6,14 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/09 17:38:19 by adjoly #+# #+# */ -/* Updated: 2025/03/29 16:49:11 by adjoly ### ########.fr */ +/* Updated: 2025/03/30 15:14:17 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #include "Form.hpp" #include "Bureaucrat.hpp" -Form::Form(void) : _name(""), _signed(false), _minForExec(1), _minForSign(1) { +Form::Form(void) : _name(""), _signed(false), _minForSign(1), _minForExec(1) { _log("➕", "Form", "", "default constructor called"); } Form::Form(std::string name, uint8_t minForSign, uint8_t minForExec) @@ -25,17 +25,17 @@ Form::Form(std::string name, uint8_t minForSign, uint8_t minForExec) Form::~Form(void) { _log("➖", "Form", "", "destructor called"); } const char *Form::GradeTooHighException::what() const throw() { - return ("Grade is too high"); + return ("grade is too high"); } const char *Form::GradeTooLowException::what() const throw() { - return ("Grade is too low"); + 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; } +std::string Form::getName(void) const { return _name; } +bool Form::getSigned(void) const { return _signed; } +uint8_t Form::getMinForSign(void) const { return _minForSign; } +uint8_t Form::getMinForExec(void) const { return _minForExec; } void Form::beSigned(Bureaucrat b) { if (_minForSign > b.getGrade()) { @@ -45,5 +45,6 @@ void Form::beSigned(Bureaucrat b) { } std::ostream &operator<<(std::ostream &os, Form &val) { - os << "Form: " << val.getName() << ", minGrade to sign: " << + os << "Form: " << val.getName() << ", minGrade to sign: " << val.getMinForSign() << ", min grade to execute: " << val.getMinForExec() << std::endl; + return (os); } diff --git a/ex01/Form.hpp b/ex01/Form.hpp index 7681545..582ab98 100644 --- a/ex01/Form.hpp +++ b/ex01/Form.hpp @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/08 20:10:59 by adjoly #+# #+# */ -/* Updated: 2025/03/29 15:43:02 by adjoly ### ########.fr */ +/* Updated: 2025/03/30 15:11:58 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,8 +18,9 @@ void _log(std::string emoji, std::string what, std::string who, std::string str); typedef unsigned char uint8_t; - -class Bureaucrat; + +#include "Bureaucrat.hpp" +//class Bureaucrat; class Form { public: @@ -36,10 +37,10 @@ class Form { virtual const char *what() const throw(); }; - const std::string getName(void) const; - bool getSigned(void); - const uint8_t getMinForSign(void); - const uint8_t getMinForExec(void); + std::string getName(void) const; + bool getSigned(void) const; + uint8_t getMinForSign(void) const; + uint8_t getMinForExec(void) const; void beSigned(Bureaucrat); diff --git a/ex01/Makefile b/ex01/Makefile index 47d94bd..5636370 100644 --- a/ex01/Makefile +++ b/ex01/Makefile @@ -6,13 +6,13 @@ # By: adjoly +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/10/25 16:09:27 by adjoly #+# #+# # -# Updated: 2025/03/08 20:20:59 by adjoly ### ########.fr # +# Updated: 2025/03/30 15:14:32 by adjoly ### ########.fr # # # # **************************************************************************** # SHELL = bash -NAME = Bureaucrat +NAME = Form CC = c++ diff --git a/ex01/main.cpp b/ex01/main.cpp index 32e35ba..16995a1 100644 --- a/ex01/main.cpp +++ b/ex01/main.cpp @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/23 14:01:11 by adjoly #+# #+# */ -/* Updated: 2025/03/29 15:44:03 by adjoly ### ########.fr */ +/* Updated: 2025/03/30 15:13:07 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,7 +43,7 @@ int main(void) { } catch (const std::exception &e) { std::cerr << "Error : " << e.what() << std::endl; } - Form f; + Form f("le contrattt", 5, 5); su.signForm(f);