implementation phonebook class
This commit is contained in:
@@ -1,6 +1,11 @@
|
|||||||
#include "Contact.class.hpp"
|
#include "Contact.class.hpp"
|
||||||
|
|
||||||
Contact::Contact( void ) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8,32 +13,17 @@ Contact::~Contact( void ) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Contact::add_first( std::string str ) {
|
// ADD
|
||||||
this->first.assign(str);
|
void Contact::add_first( std::string str ) {this->first.assign(str);}
|
||||||
return;
|
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_last( std::string str ) {
|
void Contact::add_num( std::string str ) {this->num.assign(str);}
|
||||||
this->last.assign(str);
|
void Contact::add_secret( std::string str ) {this->secret.assign(str);}
|
||||||
return;
|
|
||||||
}
|
// GET
|
||||||
void Contact::add_nick( std::string str ) {
|
std::string Contact::get_first( void ) {return first;}
|
||||||
this->nick.assign(str);
|
std::string Contact::get_last( void ) {return last;}
|
||||||
return;
|
std::string Contact::get_nick( void ) {return nick;}
|
||||||
}
|
std::string Contact::get_num( void ) {return num;}
|
||||||
void Contact::add_num( std::string str ) {
|
std::string Contact::get_secret( void ) {return secret;}
|
||||||
this->num.assign(str);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
void Contact::add_secret( std::string str ) {
|
|
||||||
this->secret.assign(str);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ public:
|
|||||||
void add_num(std::string str);
|
void add_num(std::string str);
|
||||||
void add_secret(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();
|
void print_contact();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -1,13 +1,26 @@
|
|||||||
#include "PhoneBook.class.hpp"
|
#include "PhoneBook.class.hpp"
|
||||||
|
#include "Contact.class.hpp"
|
||||||
|
|
||||||
PhoneBook::PhoneBook( void ) {
|
PhoneBook::PhoneBook( void ) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PhoneBook::~PhoneBook( void ) {
|
PhoneBook::~PhoneBook( void ) {
|
||||||
|
|
||||||
return;
|
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.
@@ -1,34 +1,27 @@
|
|||||||
#include "PhoneBook.class.hpp"
|
#include "PhoneBook.class.hpp"
|
||||||
#include "Contact.class.hpp"
|
|
||||||
|
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
# include <string>
|
# include <string>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
Contact new_contact;
|
std::string cmd;
|
||||||
new_contact.add_first("hugo");
|
|
||||||
new_contact.add_last("lamy");
|
while (1)
|
||||||
new_contact.add_nick("hugonosaure");
|
{
|
||||||
new_contact.add_num("0123456789");
|
std::getline(std::cin, cmd);
|
||||||
new_contact.add_secret("je suis un dino");
|
if (cmd.compare("ADD") == 0)
|
||||||
new_contact.print_contact();
|
std::cout << "it works !" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* class PhoneBook :
|
* class PhoneBook :
|
||||||
* add_contact (->Contact.create_contact)
|
* add_contact
|
||||||
* search_contact
|
* print_phonebook
|
||||||
* print_phonebook (->Contact.get_index/name/last/nick)
|
* search_by_index
|
||||||
* index_print (Contact.print_contact)
|
|
||||||
* exit
|
* exit
|
||||||
*
|
|
||||||
* class Contact :
|
|
||||||
* create_contact (first ; last ; nick ; num ; secret)
|
|
||||||
* get_first
|
|
||||||
* get_last
|
|
||||||
* get_nick
|
|
||||||
* print_contact
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user