From 381dc87b02a69e29cc610802ec4dbf210d0bf150 Mon Sep 17 00:00:00 2001 From: Adam JOLY Date: Mon, 4 Nov 2024 10:45:04 +0100 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=94=A8=E3=80=8D=20fix(Phonebook)?= =?UTF-8?q?:=20Fixed=20overflow=20and=20invalid=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ex01/src/PhoneBook.cpp | 6 +----- ex01/src/commands/add.cpp | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/ex01/src/PhoneBook.cpp b/ex01/src/PhoneBook.cpp index ecd93ef..59538ae 100644 --- a/ex01/src/PhoneBook.cpp +++ b/ex01/src/PhoneBook.cpp @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/26 00:20:32 by adjoly #+# #+# */ -/* Updated: 2024/11/03 18:50:17 by adjoly ### ########.fr */ +/* Updated: 2024/11/04 10:43:35 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,10 +29,6 @@ PhoneBook::PhoneBook(void) { this->_search(); else if (!input.compare("EXIT")) return ; - else if (input.empty()) - continue ; - else - std::cout << "Not a valid command" << std::endl; } } diff --git a/ex01/src/commands/add.cpp b/ex01/src/commands/add.cpp index de297a2..afd88b1 100644 --- a/ex01/src/commands/add.cpp +++ b/ex01/src/commands/add.cpp @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 13:51:00 by adjoly #+# #+# */ -/* Updated: 2024/11/03 18:06:18 by adjoly ### ########.fr */ +/* Updated: 2024/11/04 10:43:18 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -47,6 +47,6 @@ void PhoneBook::_add(void) { return ; this->_contact[this->_index].setSecret(input); this->_index++; - if (this->_index >= 8) + if (this->_index > 7) this->_index = 0; }