diff --git a/.vscode/settings.json b/.vscode/settings.json index 6499df3..bee3e86 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -50,7 +50,9 @@ "typeinfo": "cpp", "cstring": "cpp", "*.tpp": "c", - "list": "cpp" + "list": "cpp", + "map": "cpp", + "set": "cpp" }, "C_Cpp_Runner.cCompilerPath": "gcc", "C_Cpp_Runner.cppCompilerPath": "g++", diff --git a/cpp09/ex01/RPN.cpp b/cpp09/ex01/RPN.cpp index 2f2a587..361e55b 100644 --- a/cpp09/ex01/RPN.cpp +++ b/cpp09/ex01/RPN.cpp @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/06 15:04:53 by fgras-ca #+# #+# */ -/* Updated: 2024/03/06 15:40:51 by fgras-ca ### ########.fr */ +/* Updated: 2024/03/06 17:18:53 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,21 +15,22 @@ RPNCalculator::RPNCalculator() { - // Le constructeur par défaut reste inchangé. + std::cout << GREEN << "RPNCalculator default constructor called!" << RESET << std::endl; } RPNCalculator::~RPNCalculator() { - // Le destructeur reste inchangé. + std::cout << RED << "RPNCalculator is destroyed!" << RESET << std::endl; } RPNCalculator::RPNCalculator(const RPNCalculator& other) : stack(other.stack) { - // Le constructeur de copie reste inchangé. + std::cout << CYAN << "Copy constructor called for RPNCalculator." << RESET << std::endl; } RPNCalculator& RPNCalculator::operator=(const RPNCalculator& other) { + std::cout << YELLOW << "Copy assignment RPNCalculator operator called." << RESET << std::endl; if (this != &other) { this->stack = other.stack; @@ -76,7 +77,8 @@ void RPNCalculator::processToken(const std::string& token) } else { - if (stack.size() < 2) throw std::runtime_error("Error: Not enough operands."); + if (stack.size() < 2) + throw std::runtime_error("Error: Not enough operands."); float operand2 = stack.top(); stack.pop(); float operand1 = stack.top(); stack.pop(); @@ -86,7 +88,8 @@ void RPNCalculator::processToken(const std::string& token) case '-': stack.push(operand1 - operand2); break; case '*': stack.push(operand1 * operand2); break; case '/': - if (operand2 == 0) throw std::runtime_error("Error: Division by zero."); + if (operand2 == 0) + throw std::runtime_error("Error: Division by zero."); stack.push(operand1 / operand2); break; default: throw std::runtime_error("Error: Invalid operator."); diff --git a/cpp09/ex01/RPN.hpp b/cpp09/ex01/RPN.hpp index 2a8220f..5bc27c6 100644 --- a/cpp09/ex01/RPN.hpp +++ b/cpp09/ex01/RPN.hpp @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/06 14:49:08 by fgras-ca #+# #+# */ -/* Updated: 2024/03/06 15:42:36 by fgras-ca ### ########.fr */ +/* Updated: 2024/03/06 17:18:55 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/cpp09/ex01/main.cpp b/cpp09/ex01/main.cpp index bd6e83d..dec4d34 100644 --- a/cpp09/ex01/main.cpp +++ b/cpp09/ex01/main.cpp @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/06 15:13:10 by fgras-ca #+# #+# */ -/* Updated: 2024/03/06 15:44:07 by fgras-ca ### ########.fr */ +/* Updated: 2024/03/06 17:18:59 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/cpp09/ex02/Makefile b/cpp09/ex02/Makefile new file mode 100644 index 0000000..c9cae49 --- /dev/null +++ b/cpp09/ex02/Makefile @@ -0,0 +1,61 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: fgras-ca +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2023/12/27 20:57:42 by fgras-ca #+# #+# # +# Updated: 2024/03/06 15:58:19 by fgras-ca ### ########.fr # +# # +# **************************************************************************** # + +LOGO = @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 = pmergeme + +SRC = main.cpp \ + PmergeMe.cpp \ + +CC = c++ +CFLAGS = -Wall -Werror -Wextra -std=c++98 +RM = rm -f +OBJS = ${SRC:.cpp=.o} + +all : $(NAME) + +%.o: %.cpp + $(CC) $(CFLAGS) -c $< -o $@ + +$(NAME) : $(OBJS) + @echo "$(RED)Compilation fixed... $(DEF_COLOR)" + $(CC) $(CFLAGS) $(OBJS) -g -o $(NAME) + @echo "$(GREEN)Compilation complete. $(ORANGE)Type "./pmergeme" 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 \ No newline at end of file diff --git a/cpp09/ex02/PmergeMe.cpp b/cpp09/ex02/PmergeMe.cpp new file mode 100644 index 0000000..e69de29 diff --git a/cpp09/ex02/PmergeMe.hpp b/cpp09/ex02/PmergeMe.hpp new file mode 100644 index 0000000..5a21aab --- /dev/null +++ b/cpp09/ex02/PmergeMe.hpp @@ -0,0 +1,42 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* PmergeMe.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: fgras-ca +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/03/06 16:17:28 by fgras-ca #+# #+# */ +/* Updated: 2024/03/06 17:18:48 by fgras-ca ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef PMERGEME_HPP +#define PMERGEME_HPP + +#include +#include +#include + +class PmergeMe +{ +public: + PmergeMe(); + ~PmergeMe(); + PmergeMe(const PmergeMe& other); + PmergeMe& operator=(const PmergeMe& other); + + void sortAndDisplay(const std::vector& input); + void sortAndDisplay(const std::list& input); + +private: + template + void forJohnsonSort(Container& container); + + template + void displaySequence(const Container& sequence, const std::string& prefix); + + template + void mesureAndSort(Container& container); +}; + +#endif \ No newline at end of file diff --git a/cpp09/ex02/main.cpp b/cpp09/ex02/main.cpp new file mode 100644 index 0000000..e69de29