|
|
@ -7,12 +7,16 @@ 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 {
|
|
|
|
|
|
|
|
return this->Proprietaire;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -27,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;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -63,7 +67,7 @@ bool Contact::supprimerContact(const Personne& unContact){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Contact::afficherContactDirect() {
|
|
|
|
void Contact::afficherContactDirect() {
|
|
|
|
cout << lesContacts.size() << " Les contacts directs de " << this->Proprietaire << " sont : ";
|
|
|
|
cout << " Les contacts directs de " << this->Proprietaire << " sont : ";
|
|
|
|
for(list<const Personne*>::const_iterator it = lesContacts.cbegin(); it != lesContacts.cend(); ++it){
|
|
|
|
for(list<const Personne*>::const_iterator it = lesContacts.cbegin(); it != lesContacts.cend(); ++it){
|
|
|
|
if(it==lesContacts.cbegin())
|
|
|
|
if(it==lesContacts.cbegin())
|
|
|
|
cout << **it;
|
|
|
|
cout << **it;
|
|
|
@ -73,10 +77,25 @@ void Contact::afficherContactDirect() {
|
|
|
|
cout << "\n";
|
|
|
|
cout << "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Contact::afficherContactIndirect() {
|
|
|
|
void Contact::Recursive(list<Contact*> Contacts, set<const Personne*>* set) {
|
|
|
|
cout << lesContacts.size() << " Les contacts directs et indirects de " << this->Proprietaire << " sont : ";
|
|
|
|
for(auto Personne : lesContacts) {
|
|
|
|
if(lesContacts.size()==0)
|
|
|
|
if(set->find(Personne)!=set->end())
|
|
|
|
cout << " Aucun contact ";
|
|
|
|
continue;
|
|
|
|
|
|
|
|
set->insert(Personne);
|
|
|
|
|
|
|
|
for(Contact* contact : Contacts) {
|
|
|
|
|
|
|
|
if(*Personne == contact->getProprio()) {
|
|
|
|
|
|
|
|
contact->Recursive(Contacts,set);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Contact::afficherContactIndirect(list<Contact*> Contacts) {
|
|
|
|
|
|
|
|
cout << " Les contacts directs et indirects de " << this->Proprietaire << " sont : ";
|
|
|
|
|
|
|
|
set<const Personne*> lesPersonnes{};
|
|
|
|
|
|
|
|
Recursive(Contacts,&lesPersonnes);
|
|
|
|
|
|
|
|
for(auto& Personne : lesPersonnes)
|
|
|
|
|
|
|
|
cout << *Personne << ", ";
|
|
|
|
cout << "\n";
|
|
|
|
cout << "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|