style: added color to the ex01 of the module 01
This commit is contained in:
parent
4054309f5e
commit
0271d4b2de
4 changed files with 42 additions and 8 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -2,7 +2,9 @@ build/
|
|||
*.pdf
|
||||
*.d
|
||||
*.o
|
||||
*.txt
|
||||
phonebook
|
||||
.DS_Store
|
||||
megaphone
|
||||
job_of_dream
|
||||
BraiiiiiiinnnzzzZ
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,45 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 <cstdlib>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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] << " <name> <size>" << 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] << " <name> <size>" << 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue