zied soit firer

This commit is contained in:
Camille Chauvet 2023-06-22 20:41:12 +02:00
parent 585571872e
commit 120dfcfd83
6 changed files with 17 additions and 22 deletions

View File

@ -45,20 +45,14 @@ std::string Contact::to_string_partial() const
std::string short_first_name;
std::string short_last_name;
std::string short_nickname;
std::string short_phone_number;
std::string short_darkest_secret;
short_first_name = truncated(this->first_name);
short_last_name = truncated(this->last_name);
short_nickname = truncated(this->nickname);
short_phone_number = truncated(this->phone_number);
short_darkest_secret = truncated(this->darkest_secret);
ss << std::setw(10) << short_first_name << "|"
<< std::setw(10) << short_last_name << "|"
<< std::setw(10) << short_nickname << "|"
<< std::setw(10) << short_phone_number << "|"
<< std::setw(10) << short_darkest_secret;
<< std::setw(10) << short_nickname;
return(ss.str());
}
@ -67,11 +61,11 @@ std::string Contact::to_string_complete() const
{
std::stringstream ss;
ss << std::setw(10) << this->first_name << "|"
<< std::setw(10) << this->last_name << "|"
<< std::setw(10) << this->nickname << "|"
<< std::setw(10) << this->phone_number << "|"
<< std::setw(10) << this->darkest_secret << "|";
ss << "first name: " << this->first_name << std::endl
<< "last name: " << this->last_name << std::endl
<< "nickname: " << this->nickname << std::endl
<< "phone number: " << this->phone_number << std::endl
<< "darkest secret: " << this->darkest_secret;
return(ss.str());
}

View File

@ -1,3 +1,4 @@
#pragma once
#include <string>
#include <iostream>

View File

@ -28,14 +28,13 @@ void PhoneBook::display_contacts()
{
size_t i;
std::cout
<< " index|"
<< "first name|"
<< "last name |"
<< "nickname |"
<< "phone num.|"
<< "darkest s."
<< std::endl;
if (this->len)
std::cout
<< " index|"
<< "first name|"
<< "last name |"
<< "nickname "
<< std::endl;
for (i = 0; i < this->len; i++)
{

View File

@ -1,3 +1,4 @@
#pragma once
#include "Contact.hpp"
#include <cstddef>
@ -5,10 +6,9 @@ class PhoneBook {
private:
Contact contacts[8];
size_t number;
public:
size_t len;
public:
PhoneBook();
void add_contact(Contact &new_contact);

View File

@ -1,3 +1,4 @@
#pragma once
#include <string>
std::string truncated(const std::string str);