Update Contact.cpp

main
Joan PIERRON 3 years ago
parent 8f14d0e43e
commit d8668d4d20

@ -1,15 +1,49 @@
#include <iostream>
#include "Contact.hpp"
#include <list>
#include <algorithm>
using namespace std;
using namespace reseau;
// list<Personne>::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<const Personne*>::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<lesContacts.size();i++)
cout << "Contact ajouté " << lesContacts <<"\n";
return true;
}
// bool Contact::rechercher(const Personne& unContact){
// list<const Personne*>::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;
}

Loading…
Cancel
Save