update: module01/ex00
This commit is contained in:
parent
6e1b64938d
commit
07022df125
10 changed files with 244 additions and 2 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -3,3 +3,5 @@ build/
|
||||||
*.o
|
*.o
|
||||||
phonebook
|
phonebook
|
||||||
megaphone
|
megaphone
|
||||||
|
job_of_dream
|
||||||
|
BraiiiiiiinnnzzzZ
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ CompileFlags:
|
||||||
Compiler: clang
|
Compiler: clang
|
||||||
Add:
|
Add:
|
||||||
- "-xc++"
|
- "-xc++"
|
||||||
|
- "-stdlib=libc++"
|
||||||
- "-I/usr/local/include"
|
- "-I/usr/local/include"
|
||||||
- "-I/nix/store/pzmpyb9hxfv60vh0l67avr94h71nip1b-llvm-16.0.6-dev/include"
|
- "-I/nix/store/pzmpyb9hxfv60vh0l67avr94h71nip1b-llvm-16.0.6-dev/include"
|
||||||
- "-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
|
- "-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ CompileFlags:
|
||||||
Compiler: clang
|
Compiler: clang
|
||||||
Add:
|
Add:
|
||||||
- "-xc++"
|
- "-xc++"
|
||||||
|
- "-stdlib=libc++"
|
||||||
- "-I/usr/local/include"
|
- "-I/usr/local/include"
|
||||||
- "-I/nix/store/pzmpyb9hxfv60vh0l67avr94h71nip1b-llvm-16.0.6-dev/include"
|
- "-I/nix/store/pzmpyb9hxfv60vh0l67avr94h71nip1b-llvm-16.0.6-dev/include"
|
||||||
- "-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
|
- "-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||||
# Updated: 2024/10/21 15:58:19 by rparodi ### ########.fr #
|
# Updated: 2024/11/04 15:44:54 by rparodi ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
|
@ -25,7 +25,7 @@ CXXFLAGS = -Werror -Wextra -Wall -std=c++98 -I./includes/
|
||||||
# Flags to debug and have the dependences (can be removed for correction)
|
# Flags to debug and have the dependences (can be removed for correction)
|
||||||
CXXFLAGS += -MMD -g3
|
CXXFLAGS += -MMD -g3
|
||||||
# Flag to debug (TO REMOVE)
|
# Flag to debug (TO REMOVE)
|
||||||
CXXFLAGS += -D DEBUG=1
|
# CXXFLAGS += -D DEBUG=1
|
||||||
# Sources
|
# Sources
|
||||||
SRC = ./sources/contact.cpp\
|
SRC = ./sources/contact.cpp\
|
||||||
./sources/phonebook.cpp \
|
./sources/phonebook.cpp \
|
||||||
|
|
|
||||||
118
cpp01/ex00/Makefile
Normal file
118
cpp01/ex00/Makefile
Normal file
|
|
@ -0,0 +1,118 @@
|
||||||
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
# ::: :::::::: #
|
||||||
|
# Makefile :+: :+: :+: #
|
||||||
|
# +:+ +:+ +:+ #
|
||||||
|
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||||
|
# +#+#+#+#+#+ +#+ #
|
||||||
|
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||||
|
# Updated: 2024/11/04 15:47:26 by rparodi ### ########.fr #
|
||||||
|
# #
|
||||||
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
|
||||||
|
# Name
|
||||||
|
NAME = BraiiiiiiinnnzzzZ
|
||||||
|
|
||||||
|
# Commands
|
||||||
|
CXX = c++
|
||||||
|
RM = rm -rf
|
||||||
|
|
||||||
|
# Flags
|
||||||
|
# Mandatory flags for 42 cpp
|
||||||
|
CXXFLAGS = -Werror -Wextra -Wall -std=c++98 -I./includes/
|
||||||
|
# Flags to debug and have the dependences (can be removed for correction)
|
||||||
|
CXXFLAGS += -MMD -g3
|
||||||
|
# Flag to debug (TO REMOVE)
|
||||||
|
# CXXFLAGS += -D DEBUG=1
|
||||||
|
# Sources
|
||||||
|
SRC = Zombie.cpp \
|
||||||
|
newZombie.cpp \
|
||||||
|
randomChump.cpp \
|
||||||
|
main.cpp
|
||||||
|
|
||||||
|
# Objects
|
||||||
|
OBJDIRNAME = ./build
|
||||||
|
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.cpp=.o))
|
||||||
|
|
||||||
|
# Colors
|
||||||
|
GREEN = \033[32m
|
||||||
|
GREY = \033[0;90m
|
||||||
|
RED = \033[0;31m
|
||||||
|
GOLD = \033[38;5;220m
|
||||||
|
END = \033[0m
|
||||||
|
|
||||||
|
# Rules
|
||||||
|
|
||||||
|
# All (make all)
|
||||||
|
all: header $(NAME) footer
|
||||||
|
|
||||||
|
# Bonus (make bonus)
|
||||||
|
bonus: header $(OBJ) footer
|
||||||
|
@mkdir -p $(OBJDIRNAME)
|
||||||
|
@printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n'
|
||||||
|
@$(CXX) $(CXXFLAGS) -o $(NAME) $(OBJ)
|
||||||
|
|
||||||
|
# Clean (make clean)
|
||||||
|
clean:
|
||||||
|
@printf '$(GREY) Removing $(END)$(RED)Objects$(END)\n'
|
||||||
|
@printf '$(GREY) Removing $(END)$(RED)Objects Folder$(END)\n'
|
||||||
|
@$(RM) $(OBJDIRNAME)
|
||||||
|
|
||||||
|
# Clean (make fclean)
|
||||||
|
fclean: clean
|
||||||
|
@printf '$(GREY) Removing $(END)$(RED)Program$(END)\n'
|
||||||
|
@$(RM) $(NAME)
|
||||||
|
@echo ""
|
||||||
|
|
||||||
|
# Restart (make re)
|
||||||
|
re: header fclean all
|
||||||
|
|
||||||
|
# Dependences for all
|
||||||
|
$(NAME): $(OBJ)
|
||||||
|
@mkdir -p $(OBJDIRNAME)
|
||||||
|
@printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n'
|
||||||
|
@$(CXX) $(CXXFLAGS) -o $(NAME) $(OBJ)
|
||||||
|
|
||||||
|
# Creating the objects
|
||||||
|
$(OBJDIRNAME)/%.o: %.cpp
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
@printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n'
|
||||||
|
@$(CXX) $(CXXFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
# Header
|
||||||
|
header:
|
||||||
|
@clear
|
||||||
|
@printf '\n\n'
|
||||||
|
@printf '$(GOLD) ******* ****** ******* $(END)\n'
|
||||||
|
@printf '$(GOLD) ****** *** ******* $(END)\n'
|
||||||
|
@printf '$(GOLD) ******* * ******* $(END)\n'
|
||||||
|
@printf '$(GOLD) ****** ******* $(END)\n'
|
||||||
|
@printf '$(GOLD) ******* ******* $(END)\n'
|
||||||
|
@printf '$(GOLD) ******************* ******* * $(END)\n'
|
||||||
|
@printf '$(GOLD) ******************* ******* *** $(END)\n'
|
||||||
|
@printf '$(GOLD) ****** ******* ****** $(END)\n'
|
||||||
|
@printf '$(GOLD) ****** $(END)\n'
|
||||||
|
@printf '$(GOLD) ****** $(END)\n'
|
||||||
|
@printf '$(GREY) Made by rparodi$(END)\n\n'
|
||||||
|
|
||||||
|
# Footer
|
||||||
|
footer:
|
||||||
|
@printf "\n"
|
||||||
|
@printf "$(GOLD) ,_ _,$(END)\n"
|
||||||
|
@printf "$(GOLD) | \\___//|$(END)\n"
|
||||||
|
@printf "$(GOLD) |=6 6=|$(END)\n"
|
||||||
|
@printf "$(GOLD) \\=._Y_.=/$(END)\n"
|
||||||
|
@printf "$(GOLD) ) \` ( ,$(END)\n"
|
||||||
|
@printf "$(GOLD) / \\ (('$(END)\n"
|
||||||
|
@printf "$(GOLD) | | ))$(END)\n"
|
||||||
|
@printf "$(GOLD) /| | | |\\_//$(END)\n"
|
||||||
|
@printf "$(GOLD) \\| |._.| |/-\`$(END)\n"
|
||||||
|
@printf "$(GOLD) '\"' '\"'$(END)\n"
|
||||||
|
@printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n'
|
||||||
|
|
||||||
|
# Phony
|
||||||
|
.PHONY: all bonus clean fclean re
|
||||||
|
|
||||||
|
-include ${OBJ:.o=.d}
|
||||||
28
cpp01/ex00/Zombie.cpp
Normal file
28
cpp01/ex00/Zombie.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* Zombie.cpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/11/04 16:10:21 by rparodi #+# #+# */
|
||||||
|
/* Updated: 2024/11/04 16:34:30 by rparodi ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "Zombie.hpp"
|
||||||
|
|
||||||
|
Zombie::Zombie( std::string name )
|
||||||
|
{
|
||||||
|
_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
Zombie::~Zombie()
|
||||||
|
{
|
||||||
|
std::cout << "Zombie's hunter: killed " << _name << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Zombie::announce()
|
||||||
|
{
|
||||||
|
std::cout << _name << ": BraiiiiiiinnnzzzZ..." << std::endl;
|
||||||
|
}
|
||||||
32
cpp01/ex00/Zombie.hpp
Normal file
32
cpp01/ex00/Zombie.hpp
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* Zombie.hpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/11/04 16:03:03 by rparodi #+# #+# */
|
||||||
|
/* Updated: 2024/11/04 16:31:17 by rparodi ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef ZOMBIE_HPP
|
||||||
|
# define ZOMBIE_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
class Zombie
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Zombie(std::string name);
|
||||||
|
~Zombie();
|
||||||
|
void announce(void);
|
||||||
|
private:
|
||||||
|
std::string _name;
|
||||||
|
};
|
||||||
|
|
||||||
|
Zombie* newZombie( std::string name );
|
||||||
|
void randomChump( std::string name );
|
||||||
|
|
||||||
|
#endif
|
||||||
22
cpp01/ex00/main.cpp
Normal file
22
cpp01/ex00/main.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* main.cpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/11/04 15:48:46 by rparodi #+# #+# */
|
||||||
|
/* Updated: 2024/11/04 16:40:59 by rparodi ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "Zombie.hpp"
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
Zombie roger = Zombie("Roger");
|
||||||
|
roger.announce();
|
||||||
|
Zombie *nathe = newZombie("Na");
|
||||||
|
nathe->announce();
|
||||||
|
delete nathe;
|
||||||
|
randomChump("Brancheuh");
|
||||||
|
}
|
||||||
19
cpp01/ex00/newZombie.cpp
Normal file
19
cpp01/ex00/newZombie.cpp
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* newZombie.cpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/11/04 16:06:25 by rparodi #+# #+# */
|
||||||
|
/* Updated: 2024/11/04 16:32:48 by rparodi ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "Zombie.hpp"
|
||||||
|
|
||||||
|
Zombie* newZombie( std::string name )
|
||||||
|
{
|
||||||
|
Zombie *ret = new Zombie(name);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
19
cpp01/ex00/randomChump.cpp
Normal file
19
cpp01/ex00/randomChump.cpp
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* randomChump.cpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/11/04 16:31:29 by rparodi #+# #+# */
|
||||||
|
/* Updated: 2024/11/04 16:32:51 by rparodi ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "Zombie.hpp"
|
||||||
|
|
||||||
|
void randomChump( std::string name )
|
||||||
|
{
|
||||||
|
Zombie temp = Zombie(name);
|
||||||
|
temp.announce();
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue