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

@@ -1,45 +1,2 @@
**Edit a file, create a new file, and clone from Bitbucket in under 2 minutes**
gdp tuto : https://u.osu.edu/cstutorials/2018/09/28/how-to-debug-c-program-using-gdb-in-6-simple-steps/
When you're done, you can delete the content in this README and update the file with details for others getting started with your repository.
*We recommend that you open this README in another tab as you perform the tasks below. You can [watch our video](https://youtu.be/0ocf7u76WSo) for a full demo of all the steps in this tutorial. Open the video in a new tab to avoid leaving Bitbucket.*
---
## Edit a file
Youll start by editing this README file to learn how to edit a file in Bitbucket.
1. Click **Source** on the left side.
2. Click the README.md link from the list of files.
3. Click the **Edit** button.
4. Delete the following text: *Delete this line to make a change to the README from Bitbucket.*
5. After making your change, click **Commit** and then **Commit** again in the dialog. The commit page will open and youll see the change you just made.
6. Go back to the **Source** page.
---
## Create a file
Next, youll add a new file to this repository.
1. Click the **New file** button at the top of the **Source** page.
2. Give the file a filename of **contributors.txt**.
3. Enter your name in the empty file space.
4. Click **Commit** and then **Commit** again in the dialog.
5. Go back to the **Source** page.
Before you move on, go ahead and explore the repository. You've already seen the **Source** page, but check out the **Commits**, **Branches**, and **Settings** pages.
---
## Clone a repository
Use these steps to clone from SourceTree, our client for using the repository command-line free. Cloning allows you to work on your files locally. If you don't yet have SourceTree, [download and install first](https://www.sourcetreeapp.com/). If you prefer to clone from the command line, see [Clone a repository](https://confluence.atlassian.com/x/4whODQ).
1. Youll see the clone button under the **Source** heading. Click that button.
2. Now click **Check out in SourceTree**. You may need to create a SourceTree account or log in.
3. When you see the **Clone New** dialog in SourceTree, update the destination path and name if youd like to and then click **Clone**.
4. Open the directory you just created to see your repositorys files.
Now that you're more familiar with your Bitbucket repository, go ahead and add a new file locally. You can [push your change back to Bitbucket with SourceTree](https://confluence.atlassian.com/x/iqyBMg), or you can [add, commit,](https://confluence.atlassian.com/x/8QhODQ) and [push from the command line](https://confluence.atlassian.com/x/NQ0zDQ).

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.

View File

@@ -1,13 +0,0 @@
#include <iostream>
int main(int ac, char **av)
{
if (ac < 2)
std::cout << std::uppercase << "shhhhh... I think the students are asleep...";
else
for (int i = 1; av[i] != NULL; i++)
for (int j = 0; av[i][j] != '\0'; j++)
std::cout << (char)toupper(av[i][j]);
std::cout << std::endl;
return 0;
}