phonebook class contact fonction print fonctionne

This commit is contained in:
hugogogo
2022-02-02 21:30:13 +01:00
parent cdd562216a
commit 9d45496f8b
14 changed files with 117 additions and 96 deletions

View File

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

View File

@@ -0,0 +1,22 @@
#ifndef CONTACT_CLASS_HPP
# define CONTACT_CLASS_HPP
#include <string>
class Contact {
public:
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_last (std::string str);
void add_nick (std::string str);
void print_contact();
};
#endif

View File

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

View File

@@ -0,0 +1,16 @@
//#include <string>
//#include <iomanip>
#include <cstring>
#include "PhoneBook.class.hpp"
PhoneBook::PhoneBook( void ) {
return;
}
PhoneBook::~PhoneBook( void ) {
return;
}

View File

@@ -0,0 +1,12 @@
#ifndef PHONEBOOK_CLASS_HPP
# define PHONEBOOK_CLASS_HPP
#include "Contact.class.cpp"
class PhoneBook {
public:
PhoneBook();
~PhoneBook();
Contact contact;
};
#endif

View File

@@ -1,18 +0,0 @@
//#include <string>
//#include <iomanip>
#include <iostream>
#include "Phonebook.class.hpp"
Phonebook::Phonebook( void ) {
std::cout << "hello" << std::endl;
return;
}
Phonebook::~Phonebook( void ) {
std::cout << "good bye" << std::endl;
return;
}

View File

@@ -1,10 +0,0 @@
#ifndef PHONEBOOK_CLASS_HPP
# define PHONEBOOK_CLASS_HPP
class Phonebook {
public:
Phonebook();
~Phonebook();
};
#endif

View File

@@ -1,8 +0,0 @@
#include "Phonebook.class.cpp"
int main() {
Phonebook yellow;
return 0;
}

BIN
d00/ex01/builds/PhoneBook.o Normal file

Binary file not shown.

BIN
d00/ex01/builds/main.o Normal file

Binary file not shown.

10
d00/ex01/main.cpp Normal file
View File

@@ -0,0 +1,10 @@
#include "PhoneBook.class.cpp"
#include <iostream>
int main() {
PhoneBook yellow;
yellow.contact.add_first("hugo");
yellow.contact.print_contact();
return 0;
}

BIN
d00/ex01/phonebook Executable file

Binary file not shown.