implementation phonebook class

This commit is contained in:
Hugo LAMY
2022-02-03 16:23:36 +01:00
parent aa77271631
commit 8abc2d30a9
7 changed files with 54 additions and 52 deletions

View File

@@ -1,6 +1,11 @@
#include "Contact.class.hpp"
Contact::Contact( void ) {
this->add_first("NOT DEFINED");
this->add_last("NOT DEFINED");
this->add_nick("NOT DEFINED");
this->add_num("NOT DEFINED");
this->add_secret("NOT DEFINED");
return;
}
@@ -8,32 +13,17 @@ Contact::~Contact( void ) {
return;
}
void Contact::add_first( std::string str ) {
this->first.assign(str);
return;
}
void Contact::add_last( std::string str ) {
this->last.assign(str);
return;
}
void Contact::add_nick( std::string str ) {
this->nick.assign(str);
return;
}
void Contact::add_num( std::string str ) {
this->num.assign(str);
return;
}
void Contact::add_secret( std::string str ) {
this->secret.assign(str);
return;
}
// ADD
void Contact::add_first( std::string str ) {this->first.assign(str);}
void Contact::add_last( std::string str ) {this->last.assign(str);}
void Contact::add_nick( std::string str ) {this->nick.assign(str);}
void Contact::add_num( std::string str ) {this->num.assign(str);}
void Contact::add_secret( std::string str ) {this->secret.assign(str);}
// GET
std::string Contact::get_first( void ) {return first;}
std::string Contact::get_last( void ) {return last;}
std::string Contact::get_nick( void ) {return nick;}
std::string Contact::get_num( void ) {return num;}
std::string Contact::get_secret( void ) {return secret;}
void Contact::print_contact( void ) {
std::cout << "FIRST NAME : " << this->first << std::endl;
std::cout << "LAST NAME : " << this->last << std::endl;
std::cout << "NICKNAME : " << this->nick << std::endl;
std::cout << "NUMBER : " << this->num << std::endl;
std::cout << "SECRET : " << this->secret << std::endl;
return;
}

View File

@@ -17,6 +17,12 @@ public:
void add_num(std::string str);
void add_secret(std::string str);
std::string get_first();
std::string get_last ();
std::string get_nick ();
std::string get_num();
std::string get_secret();
void print_contact();
private:

View File

@@ -1,13 +1,26 @@
#include "PhoneBook.class.hpp"
#include "Contact.class.hpp"
PhoneBook::PhoneBook( void ) {
return;
}
PhoneBook::~PhoneBook( void ) {
return;
}
/*
Contact new_contact;
new_contact.add_first(name);
new_contact.add_last("lamy");
new_contact.add_nick("hugonosaure");
new_contact.add_num("0123456789");
new_contact.add_secret("je suis un dino");
std::cout << "FIRST NAME : " << new_contact.get_first() << std::endl;
std::cout << "LAST NAME : " << new_contact.get_last() << std::endl;
std::cout << "NICKNAME : " << new_contact.get_nick() << std::endl;
std::cout << "NUMBER : " << new_contact.get_num() << std::endl;
std::cout << "SECRET : " << new_contact.get_secret() << std::endl;
*/

Binary file not shown.

Binary file not shown.

View File

@@ -1,34 +1,27 @@
#include "PhoneBook.class.hpp"
#include "Contact.class.hpp"
# include <iostream>
# include <string>
int main() {
Contact new_contact;
new_contact.add_first("hugo");
new_contact.add_last("lamy");
new_contact.add_nick("hugonosaure");
new_contact.add_num("0123456789");
new_contact.add_secret("je suis un dino");
new_contact.print_contact();
std::string cmd;
while (1)
{
std::getline(std::cin, cmd);
if (cmd.compare("ADD") == 0)
std::cout << "it works !" << std::endl;
}
return 0;
}
/*
* class PhoneBook :
* add_contact (->Contact.create_contact)
* search_contact
* print_phonebook (->Contact.get_index/name/last/nick)
* index_print (Contact.print_contact)
* add_contact
* print_phonebook
* search_by_index
* exit
*
* class Contact :
* create_contact (first ; last ; nick ; num ; secret)
* get_first
* get_last
* get_nick
* print_contact
*
*/

Binary file not shown.