diff --git a/cpp05/ex01/Form.cpp b/cpp05/ex01/Form.cpp index 5bca48d..8c17d11 100644 --- a/cpp05/ex01/Form.cpp +++ b/cpp05/ex01/Form.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/17 14:19:41 by rparodi #+# #+# */ -/* Updated: 2025/03/17 22:07:57 by rparodi ### ########.fr */ +/* Updated: 2025/03/18 09:42:55 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -80,11 +80,12 @@ std::ostream& operator<<(std::ostream& output, Form const &toPrint) { } void Form::beSigned(Bureaucrat &bureaucrat) { - if (bureaucrat.getGrade() >= this->_to_sign) { + if (bureaucrat.getGrade() > this->_to_sign) { throw FormForSupperior(); - } else if (_signed) { + } else if (_signed == true) { throw FormAlreadySigned(); - } else { + } + else { std::cout << "Bureaucrat " << bureaucrat.getName() << " signs the form " << this->_name << std::endl; this->_signed = true; } diff --git a/cpp05/ex01/Makefile b/cpp05/ex01/Makefile index 9bf635b..5c8cd60 100644 --- a/cpp05/ex01/Makefile +++ b/cpp05/ex01/Makefile @@ -24,7 +24,8 @@ CXXFLAGS = -Werror -Wextra -Wall -std=c++98 -I./includes/ # Flags to have the dependences (can be removed for correction) CXXFLAGS += -MMD # Flags to have the debug (can be removed for correction) -DEBUG += -g3 -fsanitize=address +DEBUG = -g3 +DEBUG += -fsanitize=address CXXFLAGS += $(DEBUG) # Sources diff --git a/cpp05/ex01/main.cpp b/cpp05/ex01/main.cpp index 4e93f01..a575afb 100644 --- a/cpp05/ex01/main.cpp +++ b/cpp05/ex01/main.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/16 14:47:26 by rparodi #+# #+# */ -/* Updated: 2025/03/17 20:43:54 by rparodi ### ########.fr */ +/* Updated: 2025/03/18 09:42:11 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,7 +15,6 @@ #include int main(void) { - std::cout << YELLOW << "\t\t[ Testing with the grade 0 ]" << RESET << std::endl; try { Bureaucrat b1("Roger", 0); @@ -62,21 +61,30 @@ int main(void) { } std::cout << std::endl << std::endl << b2 << std::endl << std::endl; + std::cout << b2 << std::endl; try { b2.promote(); } catch (std::exception & err) { std::cerr << RED << err.what() << RESET << std::endl; } - + std::cout << b2 << std::endl; std::cout << std::endl << YELLOW << "\t\t[ Testing the overload of the '<<' operator ]" << RESET << std::endl; Form f1("Norme to cpp", 1, 1); std::cout << f1 << std::endl; - std::cout << std::endl << YELLOW << "\t\t[ Testing beSigned() methode with a new form]" << RESET << std::endl; - f1.beSigned(b1); + std::cout << std::endl << YELLOW << "\t\t[ Testing beSigned() methode with a new form ]" << RESET << std::endl; + try { + b2.signForm(f1); + } catch (std::exception & err) { + std::cerr << RED << err.what() << RESET << std::endl; + } std::cout << f1 << std::endl; std::cout << std::endl << YELLOW << "\t\t[ Testing beSigned() methode with a signed form ]" << RESET << std::endl; - f1.beSigned(b1); + try { + b2.signForm(f1); + } catch (std::exception & err) { + std::cerr << RED << err.what() << RESET << std::endl; + } std::cout << f1 << std::endl; }