Fix: finishing this exercice
This commit is contained in:
parent
b7b92dfbcf
commit
88823cbbf1
5 changed files with 101 additions and 39 deletions
|
|
@ -6,13 +6,22 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/17 15:09:21 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/20 21:34:27 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/21 17:13:54 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "phonebook.hpp"
|
||||
#include "color.hpp"
|
||||
#include <stddef.h>
|
||||
|
||||
PhoneBook::PhoneBook()
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
array_contact[i] = Contact();
|
||||
}
|
||||
|
||||
PhoneBook::~PhoneBook()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void PhoneBook::searching_header()
|
||||
{
|
||||
|
|
@ -22,20 +31,20 @@ void PhoneBook::searching_header()
|
|||
std::cout << CLR_GREY << "|" << CLR_GOLD << std::setw(10)<< "Nickname" << CLR_RESET;
|
||||
std::cout << CLR_GREY << "|" << CLR_RESET << std::endl;
|
||||
}
|
||||
void PhoneBook::search(int max)
|
||||
void PhoneBook::search()
|
||||
{
|
||||
unsigned long long chosen;
|
||||
if (max == 0)
|
||||
if (!array_contact[0].getUsed())
|
||||
{
|
||||
std::cout << CLR_RED << "\nError:\t Don't have any contact to search in (" << __FILE_NAME__ << ":" << __LINE__ << ")\n" << std::endl;
|
||||
return;
|
||||
}
|
||||
searching_header();
|
||||
for (int i = 0; i < max; i++)
|
||||
for (int i = 0; i < 8; i++)
|
||||
array_contact[i].print();
|
||||
std::cout << "\nGive me the contact on which you want more information:" << std::endl;
|
||||
chosen = atoll(get_input("Search selection", __FILE_NAME__, __LINE__).c_str());
|
||||
if (chosen >= 0 && chosen < (unsigned long long) max)
|
||||
if (chosen >= 0 && chosen < 8 && array_contact[chosen].getUsed())
|
||||
array_contact[chosen].print_all();
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue