phonebook class contact fonction print fonctionne
This commit is contained in:
53
d00/ex01/Contact.class.cpp
Normal file
53
d00/ex01/Contact.class.cpp
Normal 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;
|
||||
|
||||
}
|
||||
22
d00/ex01/Contact.class.hpp
Normal file
22
d00/ex01/Contact.class.hpp
Normal 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
|
||||
|
||||
@@ -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)
|
||||
|
||||
16
d00/ex01/PhoneBook.class.cpp
Normal file
16
d00/ex01/PhoneBook.class.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
//#include <string>
|
||||
//#include <iomanip>
|
||||
#include <cstring>
|
||||
#include "PhoneBook.class.hpp"
|
||||
|
||||
PhoneBook::PhoneBook( void ) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
PhoneBook::~PhoneBook( void ) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
12
d00/ex01/PhoneBook.class.hpp
Normal file
12
d00/ex01/PhoneBook.class.hpp
Normal 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
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
#ifndef PHONEBOOK_CLASS_HPP
|
||||
# define PHONEBOOK_CLASS_HPP
|
||||
|
||||
class Phonebook {
|
||||
public:
|
||||
Phonebook();
|
||||
~Phonebook();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,8 +0,0 @@
|
||||
#include "Phonebook.class.cpp"
|
||||
|
||||
int main() {
|
||||
|
||||
Phonebook yellow;
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
d00/ex01/builds/PhoneBook.o
Normal file
BIN
d00/ex01/builds/PhoneBook.o
Normal file
Binary file not shown.
BIN
d00/ex01/builds/main.o
Normal file
BIN
d00/ex01/builds/main.o
Normal file
Binary file not shown.
10
d00/ex01/main.cpp
Normal file
10
d00/ex01/main.cpp
Normal 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
BIN
d00/ex01/phonebook
Executable file
Binary file not shown.
Reference in New Issue
Block a user