mirror of
https://github.com/Ladebeze66/cpp-partie-1.git
synced 2026-11-09 13:17:15 +01:00
ccp
This commit is contained in:
18
cpp01/ex01/.vscode/c_cpp_properties.json
vendored
Normal file
18
cpp01/ex01/.vscode/c_cpp_properties.json
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "linux-gcc-x64",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
"cStandard": "${default}",
|
||||
"cppStandard": "${default}",
|
||||
"intelliSenseMode": "linux-gcc-x64",
|
||||
"compilerArgs": [
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
24
cpp01/ex01/.vscode/launch.json
vendored
Normal file
24
cpp01/ex01/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "C/C++ Runner: Debug Session",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"externalConsole": false,
|
||||
"cwd": "/home/fgras-ca/Bureau/fgras-ca/CPP/cpp01/ex01",
|
||||
"program": "/home/fgras-ca/Bureau/fgras-ca/CPP/cpp01/ex01/build/Debug/outDebug",
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
105
cpp01/ex01/.vscode/settings.json
vendored
Normal file
105
cpp01/ex01/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
{
|
||||
"C_Cpp_Runner.cCompilerPath": "gcc",
|
||||
"C_Cpp_Runner.cppCompilerPath": "g++",
|
||||
"C_Cpp_Runner.debuggerPath": "gdb",
|
||||
"C_Cpp_Runner.cStandard": "",
|
||||
"C_Cpp_Runner.cppStandard": "",
|
||||
"C_Cpp_Runner.msvcBatchPath": "",
|
||||
"C_Cpp_Runner.useMsvc": false,
|
||||
"C_Cpp_Runner.warnings": [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Wpedantic",
|
||||
"-Wshadow",
|
||||
"-Wformat=2",
|
||||
"-Wcast-align",
|
||||
"-Wconversion",
|
||||
"-Wsign-conversion",
|
||||
"-Wnull-dereference"
|
||||
],
|
||||
"C_Cpp_Runner.msvcWarnings": [
|
||||
"/W4",
|
||||
"/permissive-",
|
||||
"/w14242",
|
||||
"/w14287",
|
||||
"/w14296",
|
||||
"/w14311",
|
||||
"/w14826",
|
||||
"/w44062",
|
||||
"/w44242",
|
||||
"/w14905",
|
||||
"/w14906",
|
||||
"/w14263",
|
||||
"/w44265",
|
||||
"/w14928"
|
||||
],
|
||||
"C_Cpp_Runner.enableWarnings": true,
|
||||
"C_Cpp_Runner.warningsAsError": false,
|
||||
"C_Cpp_Runner.compilerArgs": [],
|
||||
"C_Cpp_Runner.linkerArgs": [],
|
||||
"C_Cpp_Runner.includePaths": [],
|
||||
"C_Cpp_Runner.includeSearch": [
|
||||
"*",
|
||||
"**/*"
|
||||
],
|
||||
"C_Cpp_Runner.excludeSearch": [
|
||||
"**/build",
|
||||
"**/build/**",
|
||||
"**/.*",
|
||||
"**/.*/**",
|
||||
"**/.vscode",
|
||||
"**/.vscode/**"
|
||||
],
|
||||
"C_Cpp_Runner.useAddressSanitizer": false,
|
||||
"C_Cpp_Runner.useUndefinedSanitizer": false,
|
||||
"C_Cpp_Runner.useLeakSanitizer": false,
|
||||
"C_Cpp_Runner.showCompilationTime": false,
|
||||
"C_Cpp_Runner.useLinkTimeOptimization": false,
|
||||
"C_Cpp_Runner.msvcSecureNoWarnings": false,
|
||||
"files.associations": {
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"deque": "cpp",
|
||||
"string": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"random": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"new": "cpp",
|
||||
"numbers": "cpp",
|
||||
"ostream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"typeinfo": "cpp"
|
||||
}
|
||||
}
|
||||
63
cpp01/ex01/Makefile
Normal file
63
cpp01/ex01/Makefile
Normal file
@@ -0,0 +1,63 @@
|
||||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: :::::::: #
|
||||
# Makefile :+: :+: :+: #
|
||||
# +:+ +:+ +:+ #
|
||||
# By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/12/24 13:55:45 by fgras-ca #+# #+# #
|
||||
# Updated: 2023/12/24 15:34:53 by fgras-ca ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
LOGO = @echo " __, ____, ____, ____, ____ ____, ___, ____,";\
|
||||
echo "(-| (-/_| (-| \ (-|_, (-|__) (-|_, (- / (-|_,";\
|
||||
echo " _|__, _/ |, _|__/ _|__, _|__) _|__, _/__, _|__,";\
|
||||
echo "( ( ( ( ( ( ( ("
|
||||
|
||||
DEF_COLOR = \033[0m
|
||||
GRAY = \033[0;90m
|
||||
RED = \033[0;91m
|
||||
GREEN = \033[0;92m
|
||||
YELLOW = \033[0;93m
|
||||
BLUE = \033[0;94m
|
||||
MAGENTA = \033[0;95m
|
||||
CYAN = \033[0;96m
|
||||
WHITE = \033[0;97m
|
||||
ORANGE = \033[38;5;214m
|
||||
|
||||
NAME = horde
|
||||
|
||||
SRC = zombieHorde.cpp \
|
||||
main.cpp \
|
||||
Zombie.cpp \
|
||||
|
||||
OBJS = ${SRC:.cpp=.o}
|
||||
|
||||
CC = c++
|
||||
CFLAGS = -Wall -Werror -Wextra -std=c++98
|
||||
RM = rm -f
|
||||
|
||||
all : $(NAME)
|
||||
|
||||
$(NAME) : $(OBJS)
|
||||
@echo "$(RED)Compilation horde... $(DEF_COLOR)"
|
||||
$(CC) $(CFLAGS) $(OBJS) -g -o $(NAME)
|
||||
@echo "$(GREEN)Compilation complete. $(ORANGE)Type "./horde" to execute the program!!$(DEF_COLOR)"
|
||||
$(LOGO)
|
||||
|
||||
clean :
|
||||
@echo "$(RED)Deleating files objects... $(DEF_COLOR)"
|
||||
$(RM) $(OBJS)
|
||||
@echo "$(GREEN)files deleted!! $(DEF_COLOR)"
|
||||
$(LOGO)
|
||||
|
||||
fclean : clean
|
||||
@echo "$(RED)Delete program name... $(DEF_COLOR)"
|
||||
$(RM) $(NAME)
|
||||
@echo "$(GREEN)File program deleted!! $(DEF_COLOR)"
|
||||
$(LOGO)
|
||||
|
||||
re : fclean all
|
||||
|
||||
.PHONY : all clean fclean re
|
||||
39
cpp01/ex01/Zombie.cpp
Normal file
39
cpp01/ex01/Zombie.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Zombie.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/24 13:31:01 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/12/24 15:30:35 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "Zombie.hpp"
|
||||
|
||||
int Zombie::count = 0;
|
||||
|
||||
Zombie::Zombie(void) : id(++count)
|
||||
{
|
||||
std::cout << "\033[32m";
|
||||
std::cout << "Constructor called for zombie [" << id << "]" << std::endl;
|
||||
std::cout << "\033[0m";
|
||||
}
|
||||
|
||||
Zombie::~Zombie(void)
|
||||
{
|
||||
std::cout << "\033[31m";
|
||||
std::cout << "Destructor called for zombie [" << id << "]" << std::endl;
|
||||
std::cout << "\033[0m";
|
||||
}
|
||||
|
||||
void Zombie::announce(void)
|
||||
{
|
||||
std::cout << this->name << ": BraiiiiiiinnnZ..." << std::endl;
|
||||
}
|
||||
|
||||
void Zombie::setname(std::string name)
|
||||
{
|
||||
this->name = name;
|
||||
}
|
||||
35
cpp01/ex01/Zombie.hpp
Normal file
35
cpp01/ex01/Zombie.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Zombie.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/24 13:23:44 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/12/24 15:24:50 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef ZOMBIE_HPP
|
||||
# define ZOMBIE_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
class Zombie
|
||||
{
|
||||
public:
|
||||
Zombie(void);
|
||||
~Zombie(void);
|
||||
void announce(void);
|
||||
void setname(std::string name);
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
int id;
|
||||
static int count;
|
||||
};
|
||||
|
||||
Zombie* zombieHorde(int N, std::string name);
|
||||
|
||||
#endif
|
||||
BIN
cpp01/ex01/Zombie.o
Normal file
BIN
cpp01/ex01/Zombie.o
Normal file
Binary file not shown.
BIN
cpp01/ex01/horde
Executable file
BIN
cpp01/ex01/horde
Executable file
Binary file not shown.
36
cpp01/ex01/main.cpp
Normal file
36
cpp01/ex01/main.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* main.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/24 15:17:37 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/12/24 15:32:08 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "Zombie.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
int N;
|
||||
std::cout << "\033[32m";
|
||||
std::cout << "Entrez le nombre de zombies à créer: ";
|
||||
std::cout << "\033[0m";
|
||||
std::cin >> N;
|
||||
if(std::cin.fail() || N < 1)
|
||||
{
|
||||
std::cerr << "\033[31m";
|
||||
std::cerr << "Entrée invalide. Veuillez entrer un nombre entier positif!!" << std::endl;
|
||||
std::cerr << "\033[0m";
|
||||
return (1);
|
||||
}
|
||||
Zombie* horde = zombieHorde(N, "Zombie");
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
horde[i].announce();
|
||||
}
|
||||
delete[] horde;
|
||||
return (0);
|
||||
}
|
||||
BIN
cpp01/ex01/main.o
Normal file
BIN
cpp01/ex01/main.o
Normal file
Binary file not shown.
23
cpp01/ex01/zombieHorde.cpp
Normal file
23
cpp01/ex01/zombieHorde.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* zombieHorde.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/24 15:05:45 by fgras-ca #+# #+# */
|
||||
/* Updated: 2023/12/24 15:17:10 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "Zombie.hpp"
|
||||
|
||||
Zombie* zombieHorde(int N, std::string name)
|
||||
{
|
||||
Zombie *horde = new Zombie[N];
|
||||
|
||||
for(int i = 0; i < N; i++)
|
||||
horde[i].setname(name);
|
||||
|
||||
return (horde);
|
||||
}
|
||||
BIN
cpp01/ex01/zombieHorde.o
Normal file
BIN
cpp01/ex01/zombieHorde.o
Normal file
Binary file not shown.
Reference in New Issue
Block a user