Implementation 2 eme metode jusqu'a indirect

main
Maxence LANONE 3 years ago
parent 08f1457c80
commit 0475093289

@ -1,3 +1,75 @@
{
"makefile.extensionOutputFolder": "./.vscode"
"makefile.extensionOutputFolder": "./.vscode",
"files.associations": {
"thread": "cpp",
"list": "cpp",
"__bit_reference": "cpp",
"__bits": "cpp",
"__config": "cpp",
"__debug": "cpp",
"__errc": "cpp",
"__hash_table": "cpp",
"__locale": "cpp",
"__mutex_base": "cpp",
"__node_handle": "cpp",
"__nullptr": "cpp",
"__split_buffer": "cpp",
"__string": "cpp",
"__threading_support": "cpp",
"__tree": "cpp",
"__tuple": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"exception": "cpp",
"initializer_list": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"locale": "cpp",
"map": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"optional": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"set": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"variant": "cpp",
"vector": "cpp",
"__functional_base": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"utility": "cpp"
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -7,7 +7,7 @@ using namespace std;
using namespace reseau;
Contact::Contact(const Personne& Proprietaire): Proprietaire{Proprietaire} {
cout << "Contact créé " << Proprietaire << "\n";
// cout << "Contact créé " << Proprietaire << "\n";
}
const Personne& Contact::getProprio() const {
@ -16,7 +16,7 @@ const Personne& Contact::getProprio() const {
bool Contact::ajouterContact(const Personne& unContact){
if(lesContacts.empty()){
cout << "Contact ajouté " << unContact <<"\n";
// cout << "Contact ajouté " << unContact <<"\n";
lesContacts.push_back(&unContact);
return true;
}
@ -31,7 +31,7 @@ bool Contact::ajouterContact(const Personne& unContact){
return false;
}
else {
cout << "Contact ajouté " << unContact <<"\n";
// cout << "Contact ajouté " << unContact <<"\n";
lesContacts.push_back(&unContact);
return true;
}

@ -5,7 +5,7 @@ using namespace std;
using namespace reseau;
Personne::Personne(const std::string& prenom):prenom{prenom}{
cout << "Personne créée " << prenom <<"\n";
// cout << "Personne créée " << prenom <<"\n";
}
// Personne::Personne(): numPers{0}{

@ -1,10 +1,14 @@
#include <iostream>
#include <list>
#include "Personne2.h"
using namespace std;
using namespace reseau2;
list<Personne> Personne::listePersonneAll{};
Personne::Personne(const string& prenom): prenom{prenom}{
listePersonneAll.emplace_back(*this);
cout << prenom << " créé\n";
}
@ -13,23 +17,25 @@ const string& Personne::getPrenom() const {
}
bool Personne::ajoutListe(const Personne& unePersonne) {
if(lesPersonnes.empty()){
if(allPerson.empty()){
cout << "Personne ajoutée " << unePersonne <<"\n";
lesPersonnes.push_back(unePersonne);
allPerson.push_back(unePersonne);
return true;
}
if(unePersonne.getPrenom()==this->prenom)
return false;
else {
cout << "Personne ajoutée " << unePersonne <<"\n";
lesPersonnes.push_back(unePersonne);
allPerson.push_back(unePersonne);
return true;
}
}
void Personne::affichListe() {
for(list<Personne>::const_iterator it2 = lesPersonnes.cbegin(); it2 != lesPersonnes.cend(); ++it2)
cout << *it2 << "\n";
cout<<"("<<this->getPrenom()<<") : ";
for(list<Personne>::const_iterator it2 = allPerson.cbegin(); it2 != allPerson.cend(); ++it2)
cout << *it2 << " ";
cout << "\n";
}

@ -2,21 +2,27 @@
#define PERSONNE2_HPP
#include <list>
#include <map>
#include <set>
namespace reseau2 {
class Personne {
std::string prenom;
std::list<Personne*> allPerson;
// std::map<reseau2::Personne,std::list<reseau2::lesPersonnes>> map;
public:
static std::list<Personne> listePersonneAll;
Personne(const std::string& prenom);
bool ajoutListe(const Personne& unePersonne);
void affichListe();
const std::string& getPrenom() const;
~Personne();
};
std::list<reseau2::Personne> lesPersonnes{};
std::ostream& operator<<(std::ostream& os, reseau2::Personne p);
bool operator==(reseau2::Personne p1, reseau2::Personne p2);
std::ostream& operator<<(std::ostream& os, Personne p);
bool operator==(Personne p1, Personne p2);
}
#endif

@ -12,55 +12,117 @@ using this_thread::sleep_for;
void technique1(){
reseau2::Personne p1{"Bob"};
reseau2::Personne p2{"Domi"};
reseau2::Personne p3{"Anne"};
reseau2::Personne p4{"Elie"};
reseau2::Personne p5{"Cali"};
reseau2::Personne p6{"Samuel"};
reseau2::Personne p7{"Elena"};
reseau2::Personne p8{"Baptiste"};
reseau2::Personne p9{"Franck"};
reseau2::Personne p10{"Agathe"};
reseau2::Personne p11{"Louna"};
reseau2::Personne p12{"Theo"};
reseau2::Personne p13{"Morgane"};
reseau2::Personne p14{"Thibault"};
reseau2::Personne p15{"Gwen"};
p1.ajoutListe(p2);
p1.ajoutListe(p5);
p1.ajoutListe(p4);
p3.ajoutListe(p1);
p3.ajoutListe(p2);
p4.ajoutListe(p5);
p4.ajoutListe(p6);
p5.ajoutListe(p4);
p6.ajoutListe(p7);
p6.ajoutListe(p9);
p7.ajoutListe(p3);
p8.ajoutListe(p2);
p9.ajoutListe(p6);
p9.ajoutListe(p11);
p10.ajoutListe(p7);
p10.ajoutListe(p8);
p11.ajoutListe(p15);
p12.ajoutListe(p10);
p13.ajoutListe(p11);
p14.ajoutListe(p12);
p14.ajoutListe(p13);
p15.ajoutListe(p9);
p1.affichListe();
p2.affichListe();
p3.affichListe();
p4.affichListe();
p5.affichListe();
p6.affichListe();
p7.affichListe();
p8.affichListe();
p9.affichListe();
p10.affichListe();
p11.affichListe();
p12.affichListe();
p13.affichListe();
p14.affichListe();
p15.affichListe();
for (reseau2::Personne p : p1.listePersonneAll )
{
cout<<p<<" ,\n";
}
}
int technique3(){
Personne p1{"Bob"};
Personne p2{"Domi"};
Personne p3{"Anne"};
Personne p4{"Elie"};
Personne p5{"Cali"};
Personne p6{"Samuel"};
Personne p7{"Elena"};
Personne p8{"Baptiste"};
Personne p9{"Franck"};
Personne p10{"Agathe"};
Personne p11{"Louna"};
Personne p12{"Theo"};
Personne p13{"Morgane"};
Personne p14{"Thibault"};
Personne p15{"Gwen"};
list<Contact*> Contacts;
void technique3(){
reseau::Personne p1{"Bob"};
reseau::Personne p2{"Domi"};
reseau::Personne p3{"Anne"};
reseau::Personne p4{"Elie"};
reseau::Personne p5{"Cali"};
reseau::Personne p6{"Samuel"};
reseau::Personne p7{"Elena"};
reseau::Personne p8{"Baptiste"};
reseau::Personne p9{"Franck"};
reseau::Personne p10{"Agathe"};
reseau::Personne p11{"Louna"};
reseau::Personne p12{"Theo"};
reseau::Personne p13{"Morgane"};
reseau::Personne p14{"Thibault"};
reseau::Personne p15{"Gwen"};
list<reseau::Contact*> Contacts;
// cout << "----------\n";
Contact c1{p1};
reseau::Contact c1{p1};
Contacts.push_back(&c1);
Contact c2{p2};
reseau::Contact c2{p2};
Contacts.push_back(&c2);
Contact c3{p3};
reseau::Contact c3{p3};
Contacts.push_back(&c3);
Contact c4{p4};
reseau::Contact c4{p4};
Contacts.push_back(&c4);
Contact c5{p5};
reseau::Contact c5{p5};
Contacts.push_back(&c5);
Contact c6{p6};
reseau::Contact c6{p6};
Contacts.push_back(&c6);
Contact c7{p7};
reseau::Contact c7{p7};
Contacts.push_back(&c7);
Contact c8{p8};
reseau::Contact c8{p8};
Contacts.push_back(&c8);
Contact c9{p9};
reseau::Contact c9{p9};
Contacts.push_back(&c9);
Contact c10{p10};
reseau::Contact c10{p10};
Contacts.push_back(&c10);
Contact c11{p11};
reseau::Contact c11{p11};
Contacts.push_back(&c11);
Contact c12{p12};
reseau::Contact c12{p12};
Contacts.push_back(&c12);
Contact c13{p13};
reseau::Contact c13{p13};
Contacts.push_back(&c13);
Contact c14{p14};
reseau::Contact c14{p14};
Contacts.push_back(&c14);
Contact c15{p15};
reseau::Contact c15{p15};
Contacts.push_back(&c15);
// cout << "----------\n";
c1.ajouterContact(p2);
@ -234,12 +296,11 @@ int technique3(){
technique3();
break;
}
sleep_for(8s);
system("clear");
// sleep_for(8s);
// system("clear");
technique3();
break;
case 3 :
return 0;
break;
}
}

Loading…
Cancel
Save