From 0271d4b2dee3a8424b51da28f36241659e71db4b Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 5 Nov 2024 12:48:37 +0100 Subject: [PATCH] style: added color to the ex01 of the module 01 --- .gitignore | 2 ++ cpp01/ex01/Zombie.cpp | 6 +++--- cpp01/ex01/Zombie.hpp | 34 +++++++++++++++++++++++++++++++++- cpp01/ex01/main.cpp | 8 ++++---- 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 5136ef9..613ea5d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,9 @@ build/ *.pdf *.d *.o +*.txt phonebook +.DS_Store megaphone job_of_dream BraiiiiiiinnnzzzZ diff --git a/cpp01/ex01/Zombie.cpp b/cpp01/ex01/Zombie.cpp index 38ab78f..40be588 100644 --- a/cpp01/ex01/Zombie.cpp +++ b/cpp01/ex01/Zombie.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/04 16:10:21 by rparodi #+# #+# */ -/* Updated: 2024/11/04 20:22:57 by rparodi ### ########.fr */ +/* Updated: 2024/11/05 12:39:33 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,7 @@ Zombie::Zombie() Zombie::~Zombie() { - std::cout << "Zombie's hunter: killed " << _name << std::endl; + std::cout << CLR_YELLOW << "Zombie's hunter: killed " << CLR_RESET << CLR_GOLD << _name << CLR_RESET << std::endl; } void Zombie::setName( std::string name ) @@ -29,5 +29,5 @@ void Zombie::setName( std::string name ) void Zombie::announce() { - std::cout << _name << ": BraiiiiiiinnnzzzZ..." << std::endl; + std::cout << CLR_BOLD_GREEN << _name << CLR_RESET << CLR_LIGHT_GREEN <<": BraiiiiiiinnnzzzZ..." << CLR_RESET << std::endl; } diff --git a/cpp01/ex01/Zombie.hpp b/cpp01/ex01/Zombie.hpp index 357ff4f..b497501 100644 --- a/cpp01/ex01/Zombie.hpp +++ b/cpp01/ex01/Zombie.hpp @@ -6,13 +6,45 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/04 16:03:03 by rparodi #+# #+# */ -/* Updated: 2024/11/04 20:38:39 by rparodi ### ########.fr */ +/* Updated: 2024/11/05 12:33:49 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef ZOMBIE_HPP # define ZOMBIE_HPP +#define CLR_RESET "\033[0m" + +#define CLR_BLACK "\033[0;30m" +#define CLR_RED "\033[0;31m" +#define CLR_GREEN "\033[0;32m" +#define CLR_YELLOW "\033[0;33m" +#define CLR_BLUE "\033[0;34m" +#define CLR_MAGENTA "\033[0;35m" +#define CLR_CYAN "\033[0;36m" +#define CLR_WHITE "\033[0;37m" +#define CLR_GOLD "\033[38;5;220m" +#define CLR_GREY "\033[38;5;240m" + +#define CLR_LIGHT_BLACK "\033[0;90m" +#define CLR_LIGHT_RED "\033[0;91m" +#define CLR_LIGHT_GREEN "\033[0;92m" +#define CLR_LIGHT_YELLOW "\033[0;93m" +#define CLR_LIGHT_BLUE "\033[0;94m" +#define CLR_LIGHT_MAGENTA "\033[0;95m" +#define CLR_LIGHT_CYAN "\033[0;96m" +#define CLR_LIGHT_WHITE "\033[0;97m" + +#define CLR_BOLD_BLACK "\033[1;30m" +#define CLR_BOLD_RED "\033[1;31m" +#define CLR_BOLD_GREEN "\033[1;32m" +#define CLR_BOLD_YELLOW "\033[1;33m" +#define CLR_BOLD_BLUE "\033[1;34m" +#define CLR_BOLD_MAGENTA "\033[1;35m" +#define CLR_BOLD_CYAN "\033[1;36m" +#define CLR_BOLD_WHITE "\033[1;37m" + + #include #include #include diff --git a/cpp01/ex01/main.cpp b/cpp01/ex01/main.cpp index d8d8a98..e098bc4 100644 --- a/cpp01/ex01/main.cpp +++ b/cpp01/ex01/main.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/04 15:48:46 by rparodi #+# #+# */ -/* Updated: 2024/11/04 20:38:40 by rparodi ### ########.fr */ +/* Updated: 2024/11/05 12:42:33 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,20 +16,20 @@ int main(int argc, char *argv[]) { if (argc != 3) { - std::cerr << "Error:\nYou have to use a numeric argument !\nRemember the syntax:\n\t" << argv[0] << " " << std::endl; + std::cerr << CLR_RED << "Error:\nYou have to use a numeric argument !\n" << CLR_RESET << CLR_BLUE << "Remember the syntax:\n\t" << argv[0] << " " << CLR_RESET << std::endl; return 1; } std::string str(argv[2]); if (str.length() > 10) { - std::cerr << "Error:\nYou can only have an integer in parameters" << std::endl; + std::cerr << CLR_RED << "Error:\nYou can only have an integer in parameters" << CLR_RESET << std::endl; return 2; } int size = std::atoll(argv[2]); std::string name = std::string(argv[1]); if (size <= 0) { - std::cerr << "Error:\nThe number have to be positive" << std::endl; + std::cerr << CLR_RED << "Error:\nThe number have to be positive" << CLR_RESET << std::endl; return 3; }