From 1607cd1fa64b9107c8287762fc7a053cb4770703 Mon Sep 17 00:00:00 2001 From: Adam JOLY Date: Thu, 31 Oct 2024 13:41:59 +0100 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=8F=97=EF=B8=8F=E3=80=8D=20wip(P?= =?UTF-8?q?honeBook):=20Started=20phonebook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- ex01/Makefile | 5 ++- ex01/includes/Contact.hpp | 22 +++++++++- ex01/includes/PhoneBook.hpp | 6 ++- ex01/src/Contact.cpp | 64 ++++++++++++++++++++++++++++ ex01/src/{main.cpp => PhoneBook.cpp} | 9 ++-- 6 files changed, 99 insertions(+), 10 deletions(-) create mode 100644 ex01/src/Contact.cpp rename ex01/src/{main.cpp => PhoneBook.cpp} (81%) diff --git a/.gitignore b/.gitignore index 9ffafd6..f1ef84a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ obj/ -ex00/megaphone megaphone +compile_commands.json +.cache .direnv flake.lock diff --git a/ex01/Makefile b/ex01/Makefile index 277dadc..0d89583 100644 --- a/ex01/Makefile +++ b/ex01/Makefile @@ -6,7 +6,7 @@ # By: adjoly +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/10/25 16:09:27 by adjoly #+# #+# # -# Updated: 2024/10/26 00:41:40 by adjoly ### ########.fr # +# Updated: 2024/10/30 17:08:54 by adjoly ### ########.fr # # # # **************************************************************************** # @@ -20,7 +20,8 @@ SRCSDIR = src/ INCLUDES = includes/ -SRCS = main.cpp +SRCS = PhoneBook.cpp \ + Contact.cpp OBJS = $(addprefix $(OBJSDIR), $(SRCS:.cpp=.o)) diff --git a/ex01/includes/Contact.hpp b/ex01/includes/Contact.hpp index 168452c..e921d22 100644 --- a/ex01/includes/Contact.hpp +++ b/ex01/includes/Contact.hpp @@ -6,15 +6,33 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/26 00:41:12 by adjoly #+# #+# */ -/* Updated: 2024/10/26 00:44:00 by adjoly ### ########.fr */ +/* Updated: 2024/10/31 13:26:17 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once +#include + class Contact { private: - + std::string _name; + std::string _lastName; + std::string _nickname; + std::string _phoneNbr; + std::string _darkestSecret; public: + // Getter + std::string getName(); + std::string getLastName(); + std::string getNickname(); + std::string getPhoneNbr(); + std::string getSecret(); + // Setter + void setName(std::string newName); + void setLastName(std::string newLastName); + void setNickname(std::string newNickName); + void setPhoneNbr(std::string newPhoneNbr); + void setSecret(std::string newSecret); }; diff --git a/ex01/includes/PhoneBook.hpp b/ex01/includes/PhoneBook.hpp index ebb5a89..5e0f68a 100644 --- a/ex01/includes/PhoneBook.hpp +++ b/ex01/includes/PhoneBook.hpp @@ -6,15 +6,17 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/26 00:41:10 by adjoly #+# #+# */ -/* Updated: 2024/10/26 00:43:39 by adjoly ### ########.fr */ +/* Updated: 2024/10/31 12:37:10 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once +#include "Contact.hpp" + class PhoneBook { private: - + Contact _contact[8]; public: }; diff --git a/ex01/src/Contact.cpp b/ex01/src/Contact.cpp new file mode 100644 index 0000000..f3b2ff7 --- /dev/null +++ b/ex01/src/Contact.cpp @@ -0,0 +1,64 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Contact.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/10/30 17:05:12 by adjoly #+# #+# */ +/* Updated: 2024/10/31 13:33:56 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "Contact.hpp" +#include + +std::string Contact::getName() +{ + return (Contact::_name); +} + +std::string Contact::getLastName() +{ + return (Contact::_lastName); +} + +std::string Contact::getNickname() +{ + return (Contact::_nickname); +} + +std::string Contact::getPhoneNbr() +{ + return (Contact::_phoneNbr); +} + +std::string Contact::getSecret() +{ + return (Contact::_darkestSecret); +} + +void Contact::setName(std::string newName) +{ + _name = newName; +} + +void Contact::setLastName(std::string newLastName) +{ + _lastName = newLastName; +} + +void Contact::setNickname(std::string newNickname) +{ + _nickname = newNickname; +} + +void Contact::setPhoneNbr(std::string newPhoneNbr) +{ + _phoneNbr = newPhoneNbr; +} + +void Contact::setSecret(std::string newSecret) +{ + _darkestSecret = newSecret; +} diff --git a/ex01/src/main.cpp b/ex01/src/PhoneBook.cpp similarity index 81% rename from ex01/src/main.cpp rename to ex01/src/PhoneBook.cpp index d943515..af5d9c2 100644 --- a/ex01/src/main.cpp +++ b/ex01/src/PhoneBook.cpp @@ -1,15 +1,18 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* main.cpp :+: :+: :+: */ +/* PhoneBook.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/26 00:20:32 by adjoly #+# #+# */ -/* Updated: 2024/10/26 00:44:17 by adjoly ### ########.fr */ +/* Updated: 2024/10/31 13:27:11 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ -int main(int ac, char **av) +#include + +int main(void) { + }