42_CPP00/ex01/PhoneBook.cpp
Camille Chauvet 67fbbf113b init
2023-05-17 16:41:46 +00:00

37 lines
533 B
C++

#include "PhoneBook.hpp"
#include <cstddef>
#include <iostream>
#include <string>
PhoneBook::PhoneBook()
{
this->len = 0;
}
void PhoneBook::add_contact(Contact new_contact)
{
size_t i;
if (this->len < 8)
{
this->contacts[this->len] = new_contact;
this->len++;
}
else {
for (i = this->len; i < 0; i--) {
this->contacts[i] = this->contacts[i - 1];
}
this->contacts[0] = new_contact;
}
}
void PhoneBook::display_contacts()
{
size_t i;
for (i = 0; i < this->len; i++)
{
std::cout << this->contacts[i];
}
}