「✨」 feat: finished ex01 (normally)
This commit is contained in:
@ -6,11 +6,12 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 <exception>
|
||||
|
||||
void _log(std::string emoji, std::string what, std::string who,
|
||||
@ -102,7 +103,7 @@ 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;
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,14 +6,14 @@
|
||||
/* 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 */
|
||||
/* 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);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -19,7 +19,8 @@ void _log(std::string emoji, std::string what, std::string who,
|
||||
|
||||
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);
|
||||
|
||||
|
@ -6,13 +6,13 @@
|
||||
# By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# 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++
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
|
||||
|
Reference in New Issue
Block a user