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

@ -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

View File

@ -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);
}