From d8668d4d20e396d3bd33fa9a9475f367a17c1a07 Mon Sep 17 00:00:00 2001 From: jopierron Date: Tue, 8 Mar 2022 09:01:04 +0000 Subject: [PATCH] Update Contact.cpp --- src/Contact.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/src/Contact.cpp b/src/Contact.cpp index d52ac75..fcc211f 100644 --- a/src/Contact.cpp +++ b/src/Contact.cpp @@ -1,15 +1,49 @@ #include #include "Contact.hpp" +#include +#include using namespace std; using namespace reseau; +// list::iterator it = find(lesContacts.begin(), lesContacts.end(), personne) + Contact::Contact(const Personne& Proprietaire): Proprietaire{Proprietaire} { cout << "Contact créé " << Proprietaire << "\n"; } -// void Contact::ajouterContact(const Personne& unContact){ -// //push_front +bool Contact::ajouterContact(const Personne& unContact){ + // if(lesContacts.empty()){ + // lesContacts.push_front(&unContact); + // return true; + // } + if(unContact==Proprietaire) + return false; + // list::iterator it = find(lesContacts.begin(), lesContacts.end(), unContact); + // if(it!=lesContacts.end()) + // cout << "trouvé : " << *it << "\n"; + // else + // cout << "pas trouvé\n"; + // this->rechercher(unContact); + lesContacts.push_front(&unContact); + // for(int i=0;i::iterator it = find(this->lesContacts.begin(), this->lesContacts.end(),unContact); +// if(it==this->lesContacts.end()) +// return false; +// else +// return true; +// } + +// bool Wagon::ajouter(const Passager& passager){ +// if(lesPassagers.size() >= capacite) +// return false; +// lesPassagers.push_front(&passager); +// return true; // } // bool Contact::supprimerContact(const Personne& unContact){ @@ -24,3 +58,13 @@ Contact::Contact(const Personne& Proprietaire): Proprietaire{Proprietaire} { ostream& reseau::operator<<(ostream& os, Personne p){ return os << p.getNom() << " " << p.getPrenom() << " " << p.getNumTel(); } + +bool reseau::operator==(reseau::Personne p1, reseau::Personne p2){ + if(p1.getNom()==p2.getNom()){ + if(p1.getPrenom()==p2.getPrenom()){ + if(p1.getNumTel()==p2.getNumTel()) + return true; + } + } + return false; +}