Improve output formatting in main.cpp by adding color-coded print macros

This commit is contained in:
whaffman 2025-06-27 15:51:03 +02:00
parent 09e719000c
commit d0966d7704
2 changed files with 19 additions and 17 deletions

View File

@ -14,7 +14,7 @@
#define EXCEPTION BOLD BACKGROUND1 " Exception: " RESET " " #define EXCEPTION BOLD BACKGROUND1 " Exception: " RESET " "
#define INFO ITALIC BOLD UNDERLINE GREEN "Info: " #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 ITALIC BOLD UNDERLINE RED "End of scope" RESET
#define END_SCOPE_EXCEPTION ITALIC BOLD UNDERLINE RED "End of scope with exception" RESET #define END_SCOPE_EXCEPTION ITALIC BOLD UNDERLINE RED "End of scope with exception" RESET

View File

@ -6,34 +6,36 @@
#include "RobotomyRequestForm.hpp" #include "RobotomyRequestForm.hpp"
#include "ShrubberyCreationForm.hpp" #include "ShrubberyCreationForm.hpp"
#include "colors.h"
int main(void) int main(void)
{ {
try try
{ {
Bureaucrat bureaucrat("John", 1); Bureaucrat bureaucrat("John", 1);
std::cout << bureaucrat << std::endl; std::cout << PRINT << bureaucrat << std::endl;
ShrubberyCreationForm shrubberyForm("Garden"); ShrubberyCreationForm shrubberyForm("Garden");
std::cout << shrubberyForm << std::endl; std::cout << PRINT << shrubberyForm << std::endl;
bureaucrat.signForm(shrubberyForm); bureaucrat.signForm(shrubberyForm);
std::cout << shrubberyForm << std::endl; std::cout << PRINT << shrubberyForm << std::endl;
shrubberyForm.execute(bureaucrat); shrubberyForm.execute(bureaucrat);
RobotomyRequestForm robotomyForm("Alice"); RobotomyRequestForm robotomyForm("Alice");
std::cout << robotomyForm << std::endl; std::cout << PRINT << robotomyForm << std::endl;
bureaucrat.signForm(robotomyForm); bureaucrat.signForm(robotomyForm);
std::cout << robotomyForm << std::endl; std::cout << PRINT << robotomyForm << std::endl;
robotomyForm.execute(bureaucrat); robotomyForm.execute(bureaucrat);
PresidentialPardonForm pardonForm("Bob"); PresidentialPardonForm pardonForm("Bob");
std::cout << pardonForm << std::endl; std::cout << PRINT << pardonForm << std::endl;
bureaucrat.signForm(pardonForm); bureaucrat.signForm(pardonForm);
std::cout << pardonForm << std::endl; std::cout << PRINT << pardonForm << std::endl;
pardonForm.execute(bureaucrat); pardonForm.execute(bureaucrat);
} }