diff --git a/ex01/src/commands/add.cpp b/ex01/src/commands/add.cpp index afd88b1..01a4097 100644 --- a/ex01/src/commands/add.cpp +++ b/ex01/src/commands/add.cpp @@ -6,10 +6,11 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 13:51:00 by adjoly #+# #+# */ -/* Updated: 2024/11/04 10:43:18 by adjoly ### ########.fr */ +/* Updated: 2024/11/04 13:05:42 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ +#include "Contact.hpp" #include "PhoneBook.hpp" #include #include @@ -22,29 +23,37 @@ std::string getInput(std::string info) { return (input); } +void emptyContact(Contact *contact) { + contact->setName(""); + contact->setLastName(""); + contact->setNickname(""); + contact->setPhoneNbr(""); + contact->setSecret(""); +} + void PhoneBook::_add(void) { std::string input; input = getInput("name"); if (input.empty()) - return ; + return emptyContact(&this->_contact[this->_index]); this->_contact[this->_index].setName(input); input = getInput("last name"); if (input.empty()) - return ; + return emptyContact(&this->_contact[this->_index]); this->_contact[this->_index].setLastName(input); input = getInput("nickname"); if (input.empty()) - return ; + return emptyContact(&this->_contact[this->_index]); this->_contact[this->_index].setNickname(input); input = getInput("phone number"); if (input.empty()) - return ; + return emptyContact(&this->_contact[this->_index]); this->_contact[this->_index].setPhoneNbr(input); input = getInput("darkest secret"); if (input.empty()) - return ; + return emptyContact(&this->_contact[this->_index]); this->_contact[this->_index].setSecret(input); this->_index++; if (this->_index > 7)