From d0966d77041fe90606faa0668367c7cc31dca787 Mon Sep 17 00:00:00 2001 From: whaffman Date: Fri, 27 Jun 2025 15:51:03 +0200 Subject: [PATCH] Improve output formatting in main.cpp by adding color-coded print macros --- ex02/inc/colors.h | 20 ++++++++++---------- ex02/src/main.cpp | 16 +++++++++------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/ex02/inc/colors.h b/ex02/inc/colors.h index aaaf665..2275c5b 100644 --- a/ex02/inc/colors.h +++ b/ex02/inc/colors.h @@ -1,20 +1,20 @@ #ifndef COLORS_H #define COLORS_H -#define BUREAUCRAT BOLD BACKGROUND4 " Bureaucrat: " RESET " " -#define AFORM BOLD BACKGROUND5 " AForm: " RESET " " -#define SHRUBBERY_CREATION_FORM BOLD BACKGROUND10 " ShrubberyCreationForm: " RESET " " -#define ROBOTOMY_REQUEST_FORM BOLD BACKGROUND11 " RobotomyRequestForm: " RESET " " +#define BUREAUCRAT BOLD BACKGROUND4 " Bureaucrat: " RESET " " +#define AFORM BOLD BACKGROUND5 " AForm: " RESET " " +#define SHRUBBERY_CREATION_FORM BOLD BACKGROUND10 " ShrubberyCreationForm: " RESET " " +#define ROBOTOMY_REQUEST_FORM BOLD BACKGROUND11 " RobotomyRequestForm: " RESET " " #define PRESIDENTIAL_PARDON_FORM BOLD BACKGROUND9 " PresidentialPardonForm: " RESET " " -#define CONSTRUCTOR "Constructor called" -#define PARAMETERIZED_CONSTRUCTOR "Parameterized constructor called" -#define DESTRUCTOR "Destructor called" -#define COPY_CONSTRUCTOR "Copy constructor called" +#define CONSTRUCTOR "Constructor called" +#define PARAMETERIZED_CONSTRUCTOR "Parameterized constructor called" +#define DESTRUCTOR "Destructor called" +#define COPY_CONSTRUCTOR "Copy constructor called" -#define EXCEPTION BOLD BACKGROUND1 " Exception: " RESET " " +#define EXCEPTION BOLD BACKGROUND1 " Exception: " RESET " " #define INFO ITALIC BOLD UNDERLINE GREEN "Info: " -#define PRINT BOLD BACKGROUND3 " Print: " RESET " " +#define PRINT BOLD BACKGROUND7 " Print: " RESET " " #define END_SCOPE ITALIC BOLD UNDERLINE RED "End of scope" RESET #define END_SCOPE_EXCEPTION ITALIC BOLD UNDERLINE RED "End of scope with exception" RESET diff --git a/ex02/src/main.cpp b/ex02/src/main.cpp index ab4dcfa..0474eae 100644 --- a/ex02/src/main.cpp +++ b/ex02/src/main.cpp @@ -6,34 +6,36 @@ #include "RobotomyRequestForm.hpp" #include "ShrubberyCreationForm.hpp" +#include "colors.h" + int main(void) { try { Bureaucrat bureaucrat("John", 1); - std::cout << bureaucrat << std::endl; + std::cout << PRINT << bureaucrat << std::endl; ShrubberyCreationForm shrubberyForm("Garden"); - std::cout << shrubberyForm << std::endl; + std::cout << PRINT << shrubberyForm << std::endl; bureaucrat.signForm(shrubberyForm); - std::cout << shrubberyForm << std::endl; + std::cout << PRINT << shrubberyForm << std::endl; shrubberyForm.execute(bureaucrat); RobotomyRequestForm robotomyForm("Alice"); - std::cout << robotomyForm << std::endl; + std::cout << PRINT << robotomyForm << std::endl; bureaucrat.signForm(robotomyForm); - std::cout << robotomyForm << std::endl; + std::cout << PRINT << robotomyForm << std::endl; robotomyForm.execute(bureaucrat); PresidentialPardonForm pardonForm("Bob"); - std::cout << pardonForm << std::endl; + std::cout << PRINT << pardonForm << std::endl; bureaucrat.signForm(pardonForm); - std::cout << pardonForm << std::endl; + std::cout << PRINT << pardonForm << std::endl; pardonForm.execute(bureaucrat); }