This commit is contained in:
Angel Ortigosa Perez
2025-09-07 10:03:17 +02:00
commit 859690063b
30 changed files with 846 additions and 0 deletions

26
ex00/Makefile Normal file
View File

@@ -0,0 +1,26 @@
NAME=zombie
SRCS=main.cpp Zombie/Zombie.cpp Zombie/newZombie.cpp Zombie/randomChump.cpp
OBJS=$(SRCS:.cpp=.o)
CC=g++
CFLAGS=-Wall -Wextra -Werror -std=c++98
all: $(NAME)
$(NAME): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $(NAME)
%.o: %.cpp
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -f $(OBJS)
fclean: clean
rm -f $(NAME)
re: fclean all
.PHONY: all clean fclean re

33
ex00/Zombie/Zombie.cpp Normal file
View File

@@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Zombie.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/05 16:46:34 by aortigos #+# #+# */
/* Updated: 2025/09/06 01:23:34 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "Zombie.hpp"
Zombie::Zombie()
{
this->name = "NULL";
}
Zombie::~Zombie()
{
std::cout << this->name << " has died.... again..." << std::endl;
}
Zombie::Zombie(std::string str)
{
this->name = str;
}
void Zombie::announce( void )
{
std::cout << this->name << ": BraiiiiiiinnnzzzZ..." << std::endl;
}

34
ex00/Zombie/Zombie.hpp Normal file
View File

@@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Zombie.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/05 16:44:08 by aortigos #+# #+# */
/* Updated: 2025/09/06 01:22:58 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ZOMBIE_HPP
# define ZOMBIE_HPP
# include <iostream>
class Zombie
{
private:
std::string name;
public:
Zombie();
~Zombie();
Zombie(std::string str);
void announce( void );
};
Zombie* newZombie( std::string name );
void randomChump( std::string name );
#endif

22
ex00/Zombie/newZombie.cpp Normal file
View File

@@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* newZombie.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/05 17:04:19 by aortigos #+# #+# */
/* Updated: 2025/09/06 01:19:33 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "Zombie.hpp"
Zombie* newZombie( std::string name )
{
Zombie *z;
z = new Zombie(name);
return (z);
}

View File

@@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* randomChump.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/05 17:04:38 by aortigos #+# #+# */
/* Updated: 2025/09/06 01:22:01 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "Zombie.hpp"
void randomChump( std::string name )
{
Zombie *z;
z = new Zombie(name);
z->announce();
}

28
ex00/main.cpp Normal file
View File

@@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/05 16:42:21 by aortigos #+# #+# */
/* Updated: 2025/09/06 01:59:00 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "Zombie/Zombie.hpp"
int main()
{
Zombie *z;
z = newZombie("Angel");
z->announce();
randomChump("Estudiante42");
delete(z);
return (0);
}