Update Contact.cpp

main
Joan PIERRON 3 years ago
parent 50630a2270
commit b93c1521f3

@ -14,8 +14,8 @@ Contact::Contact(const Personne& Proprietaire): Proprietaire{Proprietaire} {
bool Contact::ajouterContact(const Personne& unContact){ bool Contact::ajouterContact(const Personne& unContact){
if(lesContacts.empty()){ if(lesContacts.empty()){
lesContacts.push_back(&unContact);
cout << "Contact ajouté " << unContact <<"\n"; cout << "Contact ajouté " << unContact <<"\n";
lesContacts.push_back(&unContact);
return true; return true;
} }
if(unContact==Proprietaire) if(unContact==Proprietaire)
@ -24,14 +24,15 @@ bool Contact::ajouterContact(const Personne& unContact){
return false; return false;
} }
list<const Personne*>::iterator it = find(lesContacts.begin(), lesContacts.end(), &unContact); list<const Personne*>::iterator it = find(lesContacts.begin(), lesContacts.end(), &unContact);
if(it!=lesContacts.end()) if(it!=lesContacts.end()){
cout << " Contact trouvé : " << *it << "\n"; cout << "Erreur : Personne déjà dans vos contacts : " << unContact << "\n";
else return false;
cout << "Erreur : Contact pas trouvé\n"; }
// rechercher(unContact); else {
lesContacts.push_back(&unContact); cout << "Contact ajouté " << unContact <<"\n";
// for(int i=0;i<lesContacts.size();i++) lesContacts.push_back(&unContact);
cout << "Contact ajouté " << unContact <<"\n"; return true;
}
return true; return true;
} }
@ -44,7 +45,7 @@ bool Contact::rechercher(const Personne& unContact){
} }
else else
{ {
cout << "pas trouvé1\n"; cout << "pas trouvé\n";
return false; return false;
} }
lesContacts.sort(); lesContacts.sort();

Loading…
Cancel
Save