Compare commits
2 Commits
dce65dcb84
...
908691c5da
Author | SHA1 | Date | |
---|---|---|---|
|
908691c5da | ||
|
7bc9220a7a |
@ -2,6 +2,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <iterator>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ void PhoneBook::add_contact(Contact *new_contact)
|
|||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
std::cout << std::endl << this->len << std::endl;
|
||||||
if (this->len < 8)
|
if (this->len < 8)
|
||||||
{
|
{
|
||||||
this->contacts[this->len] = new_contact;
|
this->contacts[this->len] = new_contact;
|
||||||
@ -27,7 +29,8 @@ void PhoneBook::add_contact(Contact *new_contact)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = this->len; i != 0; i--) {
|
delete this->contacts[0];
|
||||||
|
for (i = this->len - 1; i > 0; i--) {
|
||||||
this->contacts[i] = this->contacts[i - 1];
|
this->contacts[i] = this->contacts[i - 1];
|
||||||
}
|
}
|
||||||
this->contacts[0] = new_contact;
|
this->contacts[0] = new_contact;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <bits/stdc++.h>
|
#include <bits/stdc++.h>
|
||||||
|
#include <ostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../include/PhoneBook.hpp"
|
#include "../include/PhoneBook.hpp"
|
||||||
@ -34,10 +35,9 @@ Contact* read_contact()
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
return (new Contact(first_name, last_name, nickname, phone_number, darkest_secret));
|
return (new Contact(first_name, last_name, nickname, phone_number, darkest_secret));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Contact* search(PhoneBook phone_book)
|
Contact* search(PhoneBook &phone_book)
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
std::string index_str;
|
std::string index_str;
|
||||||
@ -60,7 +60,6 @@ int main()
|
|||||||
Contact* contact;
|
Contact* contact;
|
||||||
PhoneBook phone_book;
|
PhoneBook phone_book;
|
||||||
|
|
||||||
phone_book = PhoneBook();
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
std::cout << "command: ";
|
std::cout << "command: ";
|
||||||
|
Loading…
Reference in New Issue
Block a user