42_CPP00/ex01/PhoneBook.cpp

37 lines
533 B
C++
Raw Normal View History

2023-05-17 12:41:46 -04:00
#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];
}
}