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

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

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

@ -2,21 +2,27 @@
#define PERSONNE2_HPP #define PERSONNE2_HPP
#include <list> #include <list>
#include <map> #include <map>
#include <set>
namespace reseau2 { namespace reseau2 {
class Personne { class Personne {
std::string prenom; std::string prenom;
std::list<Personne*> allPerson;
// std::map<reseau2::Personne,std::list<reseau2::lesPersonnes>> map; // std::map<reseau2::Personne,std::list<reseau2::lesPersonnes>> map;
public: public:
static std::list<Personne> listePersonneAll;
Personne(const std::string& prenom); Personne(const std::string& prenom);
bool ajoutListe(const Personne& unePersonne); bool ajoutListe(const Personne& unePersonne);
void affichListe(); void affichListe();
const std::string& getPrenom() const; const std::string& getPrenom() const;
~Personne(); ~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 #endif

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

Loading…
Cancel
Save