37 lines
533 B
C++
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];
|
||
|
}
|
||
|
}
|