meilleure orga des fichiers et class contact app ok

This commit is contained in:
Hugo LAMY
2022-02-03 15:17:50 +01:00
parent 9d45496f8b
commit aa77271631
11 changed files with 79 additions and 50 deletions

View File

@@ -1,53 +1,39 @@
#include "Contact.class.hpp" #include "Contact.class.hpp"
#include <iostream>
#include <string>
Contact::Contact( void ) { Contact::Contact( void ) {
return; return;
} }
Contact::~Contact( void ) { Contact::~Contact( void ) {
return; return;
}
void Contact::add_index( std::string str ) {
this->index.assign(str);
return;
} }
void Contact::add_first( std::string str ) { void Contact::add_first( std::string str ) {
this->first.assign(str); this->first.assign(str);
return; return;
} }
void Contact::add_last( std::string str ) { void Contact::add_last( std::string str ) {
this->last.assign(str); this->last.assign(str);
return; return;
} }
void Contact::add_nick( std::string str ) { void Contact::add_nick( std::string str ) {
this->nick.assign(str); this->nick.assign(str);
return; 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;
} }
void Contact::print_contact( void ) { void Contact::print_contact( void ) {
std::cout << "INDEX : " << this->index << std::endl;
std::cout << "FIRST NAME : " << this->first << std::endl; std::cout << "FIRST NAME : " << this->first << std::endl;
std::cout << "LAST NAME : " << this->last << std::endl; std::cout << "LAST NAME : " << this->last << std::endl;
std::cout << "NICKNAME : " << this->nick << std::endl; std::cout << "NICKNAME : " << this->nick << std::endl;
std::cout << "NUMBER : " << this->num << std::endl;
std::cout << "SECRET : " << this->secret << std::endl;
return; return;
} }

View File

@@ -1,22 +1,40 @@
#ifndef CONTACT_CLASS_HPP #ifndef CONTACT_CLASS_HPP
# define CONTACT_CLASS_HPP # define CONTACT_CLASS_HPP
# include <iostream>
# include <string> # include <string>
class Contact { class Contact {
public: public:
Contact(); Contact();
~Contact(); ~Contact();
std::string index;
std::string first;
std::string last;
std::string nick;
void add_index(std::string str);
void add_first(std::string str); void add_first(std::string str);
void add_last (std::string str); void add_last (std::string str);
void add_nick (std::string str); void add_nick (std::string str);
void add_num(std::string str);
void add_secret(std::string str);
void print_contact(); void print_contact();
private:
std::string first;
std::string last;
std::string nick;
std::string num;
std::string secret;
}; };
#endif #endif
/*
* create_contact (first ; last ; nick ; num ; secret)
* get_first
* get_last
* get_nick
* print_contact
*/

View File

@@ -15,12 +15,14 @@ LIBS =
INCLUDES = -I$(D_HEADERS) INCLUDES = -I$(D_HEADERS)
D_HEADERS = .
HEADERS = PhoneBook.class.hpp \
PhoneBook.class.cpp
D_SRCS = . D_SRCS = .
SRCS = main.cpp \ SRCS = main.cpp \
Contact.class.cpp \
PhoneBook.class.cpp
D_HEADERS = .
HEADERS = Contact.class.hpp \
PhoneBook.class.hpp
D_OBJS = builds D_OBJS = builds
OBJS = $(SRCS:%.cpp=$(D_OBJS)/%.o) OBJS = $(SRCS:%.cpp=$(D_OBJS)/%.o)

View File

@@ -1,6 +1,3 @@
//#include <string>
//#include <iomanip>
#include <cstring>
#include "PhoneBook.class.hpp" #include "PhoneBook.class.hpp"
PhoneBook::PhoneBook( void ) { PhoneBook::PhoneBook( void ) {

View File

@@ -1,6 +1,8 @@
#ifndef PHONEBOOK_CLASS_HPP #ifndef PHONEBOOK_CLASS_HPP
# define PHONEBOOK_CLASS_HPP # define PHONEBOOK_CLASS_HPP
#include "Contact.class.cpp"
#include "Contact.class.hpp"
#include <cstring>
class PhoneBook { class PhoneBook {
public: public:

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,10 +1,34 @@
#include "PhoneBook.class.cpp" #include "PhoneBook.class.hpp"
#include "Contact.class.hpp"
# include <iostream> # include <iostream>
# include <string>
int main() { int main() {
PhoneBook yellow; Contact new_contact;
yellow.contact.add_first("hugo"); new_contact.add_first("hugo");
yellow.contact.print_contact(); 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();
return 0; return 0;
} }
/*
* class PhoneBook :
* add_contact (->Contact.create_contact)
* search_contact
* print_phonebook (->Contact.get_index/name/last/nick)
* index_print (Contact.print_contact)
* exit
*
* class Contact :
* create_contact (first ; last ; nick ; num ; secret)
* get_first
* get_last
* get_nick
* print_contact
*
*/

Binary file not shown.