Compare commits

..

1 Commits

@ -1 +0,0 @@
{"buildTargets":["bin/exe","clean"],"launchTargets":["/Users/malanone/SAE2.02/sae2.02-2/bin>exe()"],"customConfigurationProvider":{"workspaceBrowse":{"browsePath":["/Users/malanone/SAE2.02/sae2.02-2/src"],"compilerArgs":["-Wall","-c","src/main.cpp","-o","obj/main.o"],"compilerPath":"/usr/bin/g++","standard":"c++17","windowsSdkVersion":""},"fileIndex":[["/Users/malanone/SAE2.02/sae2.02-2/src/Contact.cpp",{"uri":{"$mid":1,"fsPath":"/Users/malanone/SAE2.02/sae2.02-2/src/Contact.cpp","path":"/Users/malanone/SAE2.02/sae2.02-2/src/Contact.cpp","scheme":"file"},"configuration":{"defines":[],"standard":"c++17","includePath":[],"forcedInclude":[],"compilerPath":"/usr/bin/g++","compilerArgs":["-Wall","-c","src/Contact.cpp","-o","obj/Contact.o"],"windowsSdkVersion":""},"compileCommand":{"command":"g++ -std=c++17 -Wall -c src/Contact.cpp -o obj/Contact.o","directory":"/Users/malanone/SAE2.02/sae2.02-2","file":"/Users/malanone/SAE2.02/sae2.02-2/src/Contact.cpp"}}],["/Users/malanone/SAE2.02/sae2.02-2/src/Contact3.cpp",{"uri":{"$mid":1,"fsPath":"/Users/malanone/SAE2.02/sae2.02-2/src/Contact3.cpp","path":"/Users/malanone/SAE2.02/sae2.02-2/src/Contact3.cpp","scheme":"file"},"configuration":{"defines":[],"standard":"c++17","includePath":[],"forcedInclude":[],"compilerPath":"/usr/bin/g++","compilerArgs":["-Wall","-c","src/Contact3.cpp","-o","obj/Contact3.o"],"windowsSdkVersion":""},"compileCommand":{"command":"g++ -std=c++17 -Wall -c src/Contact3.cpp -o obj/Contact3.o","directory":"/Users/malanone/SAE2.02/sae2.02-2","file":"/Users/malanone/SAE2.02/sae2.02-2/src/Contact3.cpp"}}],["/Users/malanone/SAE2.02/sae2.02-2/src/Personne.cpp",{"uri":{"$mid":1,"fsPath":"/Users/malanone/SAE2.02/sae2.02-2/src/Personne.cpp","path":"/Users/malanone/SAE2.02/sae2.02-2/src/Personne.cpp","scheme":"file"},"configuration":{"defines":[],"standard":"c++17","includePath":[],"forcedInclude":[],"compilerPath":"/usr/bin/g++","compilerArgs":["-Wall","-c","src/Personne.cpp","-o","obj/Personne.o"],"windowsSdkVersion":""},"compileCommand":{"command":"g++ -std=c++17 -Wall -c src/Personne.cpp -o obj/Personne.o","directory":"/Users/malanone/SAE2.02/sae2.02-2","file":"/Users/malanone/SAE2.02/sae2.02-2/src/Personne.cpp"}}],["/Users/malanone/SAE2.02/sae2.02-2/src/Personne3.cpp",{"uri":{"$mid":1,"fsPath":"/Users/malanone/SAE2.02/sae2.02-2/src/Personne3.cpp","path":"/Users/malanone/SAE2.02/sae2.02-2/src/Personne3.cpp","scheme":"file"},"configuration":{"defines":[],"standard":"c++17","includePath":[],"forcedInclude":[],"compilerPath":"/usr/bin/g++","compilerArgs":["-Wall","-c","src/Personne3.cpp","-o","obj/Personne3.o"],"windowsSdkVersion":""},"compileCommand":{"command":"g++ -std=c++17 -Wall -c src/Personne3.cpp -o obj/Personne3.o","directory":"/Users/malanone/SAE2.02/sae2.02-2","file":"/Users/malanone/SAE2.02/sae2.02-2/src/Personne3.cpp"}}],["/Users/malanone/SAE2.02/sae2.02-2/src/main.cpp",{"uri":{"$mid":1,"fsPath":"/Users/malanone/SAE2.02/sae2.02-2/src/main.cpp","path":"/Users/malanone/SAE2.02/sae2.02-2/src/main.cpp","scheme":"file"},"configuration":{"defines":[],"standard":"c++17","includePath":[],"forcedInclude":[],"compilerPath":"/usr/bin/g++","compilerArgs":["-Wall","-c","src/main.cpp","-o","obj/main.o"],"windowsSdkVersion":""},"compileCommand":{"command":"g++ -std=c++17 -Wall -c src/main.cpp -o obj/main.o","directory":"/Users/malanone/SAE2.02/sae2.02-2","file":"/Users/malanone/SAE2.02/sae2.02-2/src/main.cpp"}}]]}}

11
.vscode/dryrun.log vendored

@ -1,11 +0,0 @@
make --dry-run --always-make --keep-going --print-directory
make: Entering directory `/Users/malanone/SAE2.02/sae2.02-2'
g++ -std=c++17 -Wall -c src/Contact.cpp -o obj/Contact.o
g++ -std=c++17 -Wall -c src/Contact3.cpp -o obj/Contact3.o
g++ -std=c++17 -Wall -c src/Personne.cpp -o obj/Personne.o
g++ -std=c++17 -Wall -c src/Personne3.cpp -o obj/Personne3.o
g++ -std=c++17 -Wall -c src/main.cpp -o obj/main.o
g++ obj/Contact.o obj/Contact3.o obj/Personne.o obj/Personne3.o obj/main.o -o bin/exe
make: Leaving directory `/Users/malanone/SAE2.02/sae2.02-2'

@ -1,75 +0,0 @@
{
"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"
}
}

276
.vscode/targets.log vendored

@ -1,276 +0,0 @@
make all --print-data-base --no-builtin-variables --no-builtin-rules --question
# GNU Make 3.81
# Copyright (C) 2006 Free Software Foundation, Inc.
# This is free software; see the source for copying conditions.
# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# This program built for i386-apple-darwin11.3.0
# Make data base, printed on Fri Apr 1 22:38:18 2022
# Variables
# automatic
<D = $(patsubst %/,%,$(dir $<))
# automatic
?F = $(notdir $?)
# makefile (from `Makefile', line 11)
OBJ = $(patsubst src/%.cpp,obj/%.o,$(SRC))
# makefile (from `Makefile', line 8)
SRC = $(wildcard src/*.cpp)
# environment
VSCODE_LOG_NATIVE = false
# automatic
?D = $(patsubst %/,%,$(dir $?))
# automatic
@D = $(patsubst %/,%,$(dir $@))
# automatic
@F = $(notdir $@)
# makefile
CURDIR := /Users/malanone/SAE2.02/sae2.02-2
# makefile
SHELL = /bin/sh
# environment
VSCODE_NLS_CONFIG = {"locale":"fr","availableLanguages":{"*":"fr"},"_languagePackId":"46c2c285347814a2356333ceb4dff7cd.fr","_translationsConfigFile":"/Users/malanone/Library/Application Support/Code/clp/46c2c285347814a2356333ceb4dff7cd.fr/tcf.json","_cacheRoot":"/Users/malanone/Library/Application Support/Code/clp/46c2c285347814a2356333ceb4dff7cd.fr","_resolvedLanguagePackCoreLocation":"/Users/malanone/Library/Application Support/Code/clp/46c2c285347814a2356333ceb4dff7cd.fr/e18005f0f1b33c29e81d732535d8c0e47cafb0b5","_corruptedFile":"/Users/malanone/Library/Application Support/Code/clp/46c2c285347814a2356333ceb4dff7cd.fr/corrupted.info","_languagePackSupport":true}
# environment
_ = /usr/bin/make
# makefile (from `Makefile', line 5)
CFLAGS = -std=c++17 -Wall
# makefile (from `Makefile', line 1)
MAKEFILE_LIST := Makefile
# environment
VSCODE_VERBOSE_LOGGING = true
# environment
__CFBundleIdentifier = com.microsoft.VSCode
# environment
INFOPATH = /opt/homebrew/share/info:
# environment
VSCODE_IPC_HOOK_EXTHOST = /var/folders/2c/84f5fdhx7xb36m9x0bh2cd9c0000gn/T/vscode-ipc-b861592a-2ed3-48f1-a40c-83e271989f05.sock
# environment
VSCODE_CWD = /
# environment
PATH = /opt/local/bin:/opt/local/sbin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
# environment
VSCODE_LOG_STACK = false
# environment
ELECTRON_RUN_AS_NODE = 1
# default
.FEATURES := target-specific order-only second-expansion else-if archives jobserver check-symlink
# environment
SSH_AUTH_SOCK = /private/tmp/com.apple.launchd.BVHmcK3OBC/Listeners
# automatic
%F = $(notdir $%)
# environment
VSCODE_PIPE_LOGGING = true
# environment
PWD = /Users/malanone/SAE2.02/sae2.02-2
# environment
HOMEBREW_CELLAR = /opt/homebrew/Cellar
# environment
ORIGINAL_XDG_CURRENT_DESKTOP = undefined
# environment
MANPATH = /opt/local/share/man:/opt/homebrew/share/man::
# environment
VSCODE_AMD_ENTRYPOINT = vs/workbench/api/node/extensionHostProcess
# environment
HOME = /Users/malanone
# default
MAKEFILEPATH = $(shell /usr/bin/xcode-select -print-path 2>/dev/null || echo /Developer)/Makefiles
# environment
VSCODE_CODE_CACHE_PATH = /Users/malanone/Library/Application Support/Code/CachedData/e18005f0f1b33c29e81d732535d8c0e47cafb0b5
# environment
LOGNAME = malanone
# environment
APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL = 1
# environment
VSCODE_HANDLES_UNCAUGHT_ERRORS = true
# automatic
^D = $(patsubst %/,%,$(dir $^))
# environment
XPC_FLAGS = 0x0
# default
MAKE = $(MAKE_COMMAND)
# default
MAKECMDGOALS := all
# environment
SHLVL = 1
# makefile (from `Makefile', line 2)
CC = g++
# default
MAKE_VERSION := 3.81
# environment
USER = malanone
# makefile
.DEFAULT_GOAL := bin/exe
# automatic
%D = $(patsubst %/,%,$(dir $%))
# default
MAKE_COMMAND := /Library/Developer/CommandLineTools/usr/bin/make
# default
.VARIABLES :=
# environment
TMPDIR = /var/folders/2c/84f5fdhx7xb36m9x0bh2cd9c0000gn/T/
# automatic
*F = $(notdir $*)
# environment
VSCODE_IPC_HOOK = /Users/malanone/Library/Application Support/Code/1.66.0-main.sock
# makefile
MAKEFLAGS = Rrqp
# environment
PROMPT = %B%F{blue}%n%f%b%F{green}@%m%f %F{red}%~%f %F{green}%#%f
# environment
MFLAGS = -Rrqp
# automatic
*D = $(patsubst %/,%,$(dir $*))
# environment
XPC_SERVICE_NAME = application.com.microsoft.VSCode.14373281.14373287
# environment
HOMEBREW_PREFIX = /opt/homebrew
# automatic
+D = $(patsubst %/,%,$(dir $+))
# automatic
+F = $(notdir $+)
# environment
HOMEBREW_REPOSITORY = /opt/homebrew
# environment
__CF_USER_TEXT_ENCODING = 0x1F5:0x0:0x1
# environment
COMMAND_MODE = unix2003
# default
MAKEFILES :=
# automatic
<F = $(notdir $<)
# environment
LC_ALL = C
# automatic
^F = $(notdir $^)
# default
SUFFIXES :=
# default
.INCLUDE_DIRS = /usr/local/include
# environment
MAKELEVEL := 0
# environment
LANG = C
# environment
VSCODE_PID = 70352
# variable set hash-table stats:
# Load=72/1024=7%, Rehash=0, Collisions=3/98=3%
# Pattern-specific Variable Values
# No pattern-specific variable values.
# Directories
# . (device 16777232, inode 14483492): 13 files, no impossibilities.
# src (device 16777232, inode 14483585): 12 files, no impossibilities.
# 25 files, no impossibilities in 2 directories.
# Implicit Rules
obj/%.o: src/%.cpp
# commands to execute (from `Makefile', line 20):
$(CC) $(CFLAGS) -c $< -o $@
# 1 implicit rules, 0 (0.0%) terminal.
# Files
# Not a target:
obj/Contact3.o:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# Not a target:
all:
# Command-line target.
# Implicit rule search has been done.
# File does not exist.
# File has not been updated.
# variable set hash-table stats:
# Load=0/32=0%, Rehash=0, Collisions=0/0=0%
# Not a target:
obj/Contact.o:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# Not a target:
obj/main.o:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# Not a target:
.SUFFIXES:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# Not a target:
Makefile:
# Implicit rule search has been done.
# Last modified 2022-04-01 22:38:14
# File has been updated.
# Successfully updated.
# variable set hash-table stats:
# Load=0/32=0%, Rehash=0, Collisions=0/0=0%
bin/exe: obj/Contact.o obj/Contact3.o obj/Personne.o obj/Personne3.o obj/main.o
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# commands to execute (from `Makefile', line 16):
$(CC) $(OBJ) -o $@
# Not a target:
.DEFAULT:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# Not a target:
obj/Personne3.o:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
clean:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# commands to execute (from `Makefile', line 24):
rm obj/*.o bin/exe
# Not a target:
obj/Personne.o:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# files hash-table stats:
# Load=11/1024=1%, Rehash=0, Collisions=0/28=0%
# VPATH Search Paths
# No `vpath' search paths.
# No general (`VPATH' variable) search path.
# # of strings in strcache: 1
# # of strcache buffers: 1
# strcache size: total = 4096 / max = 4096 / min = 4096 / avg = 4096
# strcache free: total = 4087 / max = 4087 / min = 4087 / avg = 4087
# Finished Make data base on Fri Apr 1 22:38:18 2022
make: *** No rule to make target `all'. Stop.

@ -1,9 +0,0 @@
L'algorithme de Dijkstra
On part d'une personne qui possède un répertoire de contacts.
Elle peut alors envoyer directement un message à ses contacts.
On les implémente dans une map où l'on aura un arbre binaire qui va nous permettre de savoir par où on est déjà passer.
Ensuite au bout de chaque personne qui sont en contact direct, elles aussi peuvent envoyer un messages aux personnes de leur répertoire.

@ -16,7 +16,7 @@ bin/exe: $(OBJ)
$(CC) $(OBJ) -o $@
# génération des .o à partir des .cpp et .hpp crrespondants :
obj/%.o: src/%.cpp
obj/%.o: src/%.cpp
$(CC) $(CFLAGS) -c $< -o $@
#nettoyage : destruction des .o et de l'exécutable
@ -24,4 +24,3 @@ clean:
rm obj/*.o bin/exe

@ -0,0 +1,2 @@
# sae2.02

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -1,182 +0,0 @@
/**
* \file Contact.cpp
* \brief On implémente les différentes fonctions et méthodes définies dans les fichiers d'en-tête. La compilation de ce fichiers .cpp nous permettra d'utiliser dans le main ces fonctions
Il inclut les définitions à partir d'un en-tête.
* \author Matis MAZINGUE Joan PIERRON Maxence LANONE Hugo PRADIER G7
* \date 31 Mars 2022
*/
#include <iostream>
#include "Contact.hpp"
#include <algorithm>
using namespace std;
using namespace reseau;
/**
* @brief Construct a new Contact:: Contact object
*
* @param Proprietaire
*/
Contact::Contact(const Personne& Proprietaire): Proprietaire{Proprietaire} {
// cout << "Contact créé " << Proprietaire << "\n";
}
/**
* @brief getter to get propriétaire
*
* @return const Personne&
*/
const Personne& Contact::getProprio() const {
return this->Proprietaire;
}
/**
* @brief
*
* @param unContact
* @return true
* @return false
*/
bool Contact::ajouterContact(const Personne& unContact){
if(lesContacts.empty()){
// cout << "Contact ajouté " << unContact <<"\n";
lesContacts.push_back(&unContact);
return true;
}
if(unContact==Proprietaire)
{
cout << "Erreur : Contact déjà existant (Proprietaire)\n";
return false;
}
list<const Personne*>::iterator it = find(lesContacts.begin(), lesContacts.end(), &unContact);
if(it!=lesContacts.end()){
cout << "Erreur : Personne déjà dans vos contacts : " << unContact << "\n";
return false;
}
else {
// cout << "Contact ajouté " << unContact <<"\n";
lesContacts.push_back(&unContact);
return true;
}
}
/**
* @brief
*
* @param unContact
* @return true
* @return false
*/
bool Contact::rechercher(const Personne& unContact){
list<const Personne*>::iterator it = find(lesContacts.begin(), lesContacts.end(),&unContact);
if(it != lesContacts.end())
{
cout << "trouvé : " << unContact << "\n";
return true;
}
else
{
cout << "pas trouvé\n";
return false;
}
lesContacts.sort();
}
/**
* @brief
*
* @param unContact
* @return true
* @return false
*/
bool Contact::supprimerContact(const Personne& unContact){
list<const Personne*>::iterator it = find(lesContacts.begin(), lesContacts.end(), &unContact);
if(it!=lesContacts.end()){
lesContacts.erase(it);
cout << "Contact " << unContact << " supprimé\n";
return true;
}
else {
cout << "Erreur : le contact n'existe pas\n";
return false;
}
}
/**
* @brief
*
*/
void Contact::afficherContactDirect() {
cout << " Les contacts directs de " << this->Proprietaire << " sont : ";
for(list<const Personne*>::const_iterator it = lesContacts.cbegin(); it != lesContacts.cend(); ++it){
if(it==lesContacts.cbegin())
cout << **it;
else
cout << ", " << **it;
}
if(lesContacts.empty())
cout << "Aucun contact ";
cout << "\n";
}
/**
* @brief
*
* @param Contacts
* @param set
*/
void Contact::Recursive(list<Contact*> Contacts, set<const Personne*>* set) {
for(const Personne* Personne : lesContacts) {
if(set->find(Personne)!=set->end())
continue;
set->insert(Personne);
for(Contact* contact : Contacts) {
if(*Personne == contact->getProprio()) {
contact->Recursive(Contacts,set);
}
}
}
}
/**
* @brief
*
* @param Contacts
*/
void Contact::afficherContactIndirect(list<Contact*> Contacts) {
cout << " Les contacts directs et indirects de " << this->Proprietaire << " sont : ";
set<const Personne*> lesPersonnes{};
Recursive(Contacts,&lesPersonnes);
if(lesPersonnes.empty())
cout << "Aucun contact ";
for(const Personne* Personne : lesPersonnes)
cout << *Personne << " ";
cout << "\n";
}
/**
* @brief
*
* @param os
* @param p
* @return ostream&
*/
ostream& reseau::operator<<(ostream& os, Personne p){
return os << p.getPrenom();
}
/**
* @brief
*
* @param p1
* @param p2
* @return true
* @return false
*/
bool reseau::operator==(reseau::Personne p1, reseau::Personne p2){
if(p1.getPrenom()==p2.getPrenom())
return true;
return false;
}

@ -1,36 +0,0 @@
/**
* \file Contact.hpp
* \brief Contient des variables, des constantes et divers types de données relatifs à notre classe Contact. Cela nous permet de stocker des composants de code.
* \author Matis MAZINGUE Joan PIERRON Maxence LANONE Hugo PRADIER G7
* \date 31 Mars 2022
*/
#ifndef CONTACT_hpp
#define CONTACT_hpp
#include"Personne.hpp"
#include<list>
#include<iostream>
#include<set>
namespace reseau{
class Contact {
reseau::Personne Proprietaire;
std::list<const reseau::Personne*> lesContacts{};
void Recursive(std::list<Contact*> Contacts, std::set<const reseau::Personne*>* set);
public:
Contact(const reseau::Personne& Proprietaire);
const Personne& getProprio() const;
bool ajouterContact(const reseau::Personne& unContact);
bool supprimerContact(const reseau::Personne& unContact);
bool rechercher(const Personne& unContact);
void afficherContactDirect();
void afficherContactIndirect(std::list<Contact*> Contacts);
// ~Contact();
};
std::ostream& operator<<(std::ostream& os, reseau::Personne p);
bool operator==(reseau::Personne p1, reseau::Personne p2);
}
#endif

@ -1,87 +0,0 @@
/**
* \file Contact3.cpp
* \brief On implémente les différentes fonctions et méthodes définies dans les fichiers d'en-tête. La compilation de ce fichiers .cpp nous permettra d'utiliser dans le main ces fonctions
Il inclut les définitions à partir d'un en-tête.
* \author Matis MAZINGUE Joan PIERRON Maxence LANONE Hugo PRADIER G7
* \date 31 Mars 2022
*/
#include <iostream>
#include "Contact3.hpp"
using namespace std;
using namespace reseau2;
/**
* @brief
*
* @return list<const Personne*>
*/
list<const Personne*> ListeContact::getValue() {
return personnes;
}
/**
* @brief
*
* @param p
*/
void ListeContact::ajtContact(const Personne& p) {
personnes.push_back(&p);
}
/**
* @brief Construct a new Liaison Personne:: Liaison Personne object
*
* @param envoyeur
* @param destinataire
*/
LiaisonPersonne::LiaisonPersonne(const Personne *envoyeur, const Personne *destinataire) : envoyeur(envoyeur), destinataire(destinataire) {}
/**
* @brief
*
* @return const Personne*
*/
const Personne* LiaisonPersonne::getEnvoyeur() const {
return envoyeur;
}
/**
* @brief
*
* @return const Personne*
*/
const Personne* LiaisonPersonne::getDestinataire() const {
return destinataire;
}
/**
* @brief Construct a new Conteneur:: Conteneur object
*
* @param pers
*/
Conteneur::Conteneur(Personne *pers) : pers(pers) {}
/**
* @brief
*
* @return std::list<const Personne*>
*/
std::list<const Personne*> Conteneur::getValue() {
cout << "test";
std::list<const Personne*> liste;
for (const LiaisonPersonne& liaisonPersonne : personnes) {
liste.push_back(liaisonPersonne.getDestinataire());
}
return liste;
}
/**
* @brief
*
* @param p
*/
void Conteneur::ajtContact(const Personne& p) {
personnes.emplace_back(pers, &p);
}

@ -1,50 +0,0 @@
/**
* \file Contact3.hpp
* \brief Contient des variables, des constantes et divers types de données relatifs à notre classe Contact. Cela nous permet de stocker des composants de code.
* \author Matis MAZINGUE Joan PIERRON Maxence LANONE Hugo PRADIER G7
* \date 31 Mars 2022
*/
#ifndef CONTACT3_hpp
#define CONTACT3_hpp
#include<list>
#include<iostream>
#include<set>
#include "Personne3.hpp"
namespace reseau2{
class Contact {
public:
virtual std::list<const Personne*> getValue() = 0;
virtual void ajtContact(const Personne& p) = 0;
virtual ~Contact() = default;
};
class ListeContact : public Contact {
std::list<const Personne*> personnes;
public:
std::list<const Personne*> getValue() override;
void ajtContact(const Personne& p) override;
};
class LiaisonPersonne {
const Personne* envoyeur;
const Personne* destinataire;
public:
LiaisonPersonne(const Personne *envoyeur, const Personne *destinataire);
const Personne *getEnvoyeur() const;
const Personne *getDestinataire() const;
};
class Conteneur : public Contact {
Personne* pers;
std::list<LiaisonPersonne> personnes;
public:
Conteneur(Personne *pers);
std::list<const Personne*> getValue() override;
void ajtContact(const Personne& p) override;
};
}
#endif

@ -1,36 +1,32 @@
/**
* \file Personne.cpp
* \brief On implémente les différentes fonctions et méthodes définies dans les fichiers d'en-tête. La compilation de ce fichiers .cpp nous permettra d'utiliser dans le main ces fonctions
Il inclut les définitions à partir d'un en-tête.
* \author Matis MAZINGUE Joan PIERRON Maxence LANONE Hugo PRADIER G7
* \date 31 Mars 2022
*/
#include <iostream>
#include "Personne.hpp"
using namespace std;
using namespace reseau;
/**
* @brief Construct a new Personne:: Personne object
*
* @param prenom
*/
Personne::Personne(const std::string& prenom):prenom{prenom}{
// cout << "Personne créée " << prenom <<"\n";
int numPers=0;
Personne::Personne(const std::string& nom, const std::string& prenom, const string& numTel): nom{nom}, prenom{prenom}, numTel{numTel}{
numPers = numPers+1;
cout << "Personne créée " << nom << " " << prenom << " " << numTel <<"\n";
}
Personne::Personne(): numPers{0}{
numPers = numPers+1;
cout << "Personne créée \n";
}
// Personne::Personne(): numPers{0}{
// cout << "Personne créée \n";
// }
const string& Personne::getNom() const{
return nom;
}
/**
* @brief
*
* @return const string&
*/
const string& Personne::getPrenom() const{
return this->prenom;
return prenom;
}
const string& Personne::getNumTel() const{
return numTel;
}
void Personne::setNumTel(const string& numTel){
this->numTel = numTel;
}

@ -1,23 +1,18 @@
/**
* \file Personne.hpp
* \brief Contient des variables, des constantes et divers types de données relatifs à notre classe Personne. Cela nous permet de stocker des composants de code.
* \author Matis MAZINGUE Joan PIERRON Maxence LANONE Hugo PRADIER G7
* \date 31 Mars 2022
*/
#ifndef PERSONNE_hpp
#define PERSONNE_hpp
namespace reseau {
class Personne {
std::string prenom;
public:
Personne(const std::string& prenom);
// Personne();
const std::string& getPrenom() const;
// ~Personne();
};
}
class Personne {
std::string nom;
std::string prenom;
std::string numTel;
public:
Personne(const std::string& nom, const std::string& prenom, const std::string& numTel);
Personne();
const std::string& getNom() const;
const std::string& getPrenom() const;
const std::string& getNumTel() const;
void setNumTel(const std::string& numTel);
// ~Personne();
};
#endif

@ -1,88 +0,0 @@
/**
* \file Personne3.cpp
* \brief On implémente les différentes fonctions et méthodes définies dans les fichiers d'en-tête. La compilation de ce fichiers .cpp nous permettra d'utiliser dans le main ces fonctions
Il inclut les définitions à partir d'un en-tête.
* \author Matis MAZINGUE Joan PIERRON Maxence LANONE Hugo PRADIER G7
* \date 31 Mars 2022
*/
#include "Personne3.hpp"
#include "Contact3.hpp"
#include <iostream>
#include <unordered_set>
#include <queue>
using namespace std;
using namespace reseau2;
// #define TECHNIQUE_A
/**
* @brief Construct a new Personne:: Personne object
*
* @param prenom
*/
Personne::Personne(const std::string& prenom):prenom{prenom}{
// #ifdef TECHNIQUE_A
contacts = new ListeContact{};
// #else
// contacts = new Conteneur{};
// #endif
}
/**
* @brief
*
* @return const string&
*/
const string& Personne::getPrenom() const{
return this->prenom;
}
/**
* @brief
*
* @param personne
*/
void reseau2::Personne::ajtContact(const Personne &personne) {
this->contacts->ajtContact(personne);
}
/**
* @brief Destroy the Personne:: Personne object
*
*/
Personne::~Personne() {
delete contacts;
}
/**
* @brief
*
* @param p
* @return true
* @return false
*/
bool Personne::peutCommuniquerA(const Personne &p) const {
unordered_set<const Personne*> visited;
queue<const Personne*> file;
file.push(this);
while (!file.empty()) {
const Personne* front = file.front();
file.pop();
for (const Personne* perso : front->contacts->getValue()) {
if (perso == &p) {
cout << this->prenom << " peut communiquer avec " << p.getPrenom() << "\n";
return true;
}
else if (visited.find(perso) == visited.end()) {
file.push(perso);
visited.insert(perso);
}
}
}
cout << this->prenom << " ne peut pas communiquer avec " << p.getPrenom() << "\n";
return false;
}

@ -1,28 +0,0 @@
/**
* \file Personne3.hpp
* \brief Contient des variables, des constantes et divers types de données relatifs à notre classe Personne. Cela nous permet de stocker des composants de code.
* \author Matis MAZINGUE Joan PIERRON Maxence LANONE Hugo PRADIER G7
* \date 31 Mars 2022
*/
#ifndef PERSONNE3_hpp
#define PERSONNE3_hpp
#include <string>
namespace reseau2 {
class Contact;
class Personne {
std::string prenom;
Contact* contacts;
public:
explicit Personne(const std::string& prenom);
void ajtContact(const Personne& personne);
const std::string& getPrenom() const;
bool peutCommuniquerA(const Personne& p) const;
~Personne();
};
}
#endif

@ -1,288 +1,15 @@
/**
* \file main.cpp
* \brief Fonctions permettant d'appeller des fonctions à l'aide d'un menu et de mettre en place un réseau
* \author Matis MAZINGUE Joan PIERRON Maxence LANONE Hugo PRADIER G7
* \date 31 Mars 2022
*/
#include <iostream>
#include "Personne3.hpp"
#include "Contact3.hpp"
#include "Personne.hpp"
#include "Contact.hpp"
#include <vector>
using namespace std;
using namespace reseau;
int main() {
/**
* \brief Main divisé en deux partie :
*
* Partie 1 : qui qui permet la création de personnes appartent au futur réseau, la création à partir de ces personnes de propriétaire possédant * une liste de contact, enfin on ajoute les contacts directs dans la liste de chaque propriétaire.
*
* Partie 2 : menu qui permet à l'utilisateur d'appeller des fonctions pour réaliser les différentes techniques, il va pouvoir pour chacune * afficher la liste de contact direct et indirect pour une ou toutes les personnes.
*
* choix, choix2, choix3, persChoix : correspond à la demande de l'utlisateur qui entraîne l'appel de la fonction souhaitée
*/
/*
On crée chaque personne qui seront dans notre réseau
*/
reseau::Personne p1{"Bob"};
reseau::Personne p2{"Domi"};
reseau::Personne p3{"Anne"};
reseau::Personne p4{"Elie"};
reseau::Personne p5{"Cali"};
reseau::Personne p6{"Samuel"};
reseau::Personne p7{"Elena"};
reseau::Personne p8{"Baptiste"};
reseau::Personne p9{"Franck"};
reseau::Personne p10{"Agathe"};
reseau::Personne p11{"Louna"};
reseau::Personne p12{"Theo"};
reseau::Personne p13{"Morgane"};
reseau::Personne p14{"Thibault"};
reseau::Personne p15{"Gwen"};
list<Contact*> Contacts;
/*
On crée les contacts en mettant leur propiétaire, on ajoute ensuite chaque contact dans une liste juste après leur construction
*/
Contact c1{p1};
Contacts.push_back(&c1);
Contact c2{p2};
Contacts.push_back(&c2);
Contact c3{p3};
Contacts.push_back(&c3);
Contact c4{p4};
Contacts.push_back(&c4);
Contact c5{p5};
Contacts.push_back(&c5);
Contact c6{p6};
Contacts.push_back(&c6);
Contact c7{p7};
Contacts.push_back(&c7);
Contact c8{p8};
Contacts.push_back(&c8);
Contact c9{p9};
Contacts.push_back(&c9);
Contact c10{p10};
Contacts.push_back(&c10);
Contact c11{p11};
Contacts.push_back(&c11);
Contact c12{p12};
Contacts.push_back(&c12);
Contact c13{p13};
Contacts.push_back(&c13);
Contact c14{p14};
Contacts.push_back(&c14);
Contact c15{p15};
Contacts.push_back(&c15);
/*
On place les contacts directs dans une liste de personne qui correspond au répertoire de chaque personne
*/
c1.ajouterContact(p2);
c1.ajouterContact(p5);
c1.ajouterContact(p4);
c3.ajouterContact(p1);
c3.ajouterContact(p2);
c4.ajouterContact(p5);
c4.ajouterContact(p6);
c5.ajouterContact(p4);
c6.ajouterContact(p7);
c6.ajouterContact(p9);
c7.ajouterContact(p3);
c8.ajouterContact(p2);
c9.ajouterContact(p6);
c9.ajouterContact(p11);
c10.ajouterContact(p7);
c10.ajouterContact(p8);
c11.ajouterContact(p15);
c12.ajouterContact(p10);
c13.ajouterContact(p11);
c14.ajouterContact(p12);
c14.ajouterContact(p13);
c15.ajouterContact(p9);
// -----------------------------------------------
reseau2::Personne pp1{"Bob"};
reseau2::Personne pp2{"Domi"};
reseau2::Personne pp3{"Anne"};
reseau2::Personne pp4{"Elie"};
reseau2::Personne pp5{"Cali"};
reseau2::Personne pp6{"Samuel"};
reseau2::Personne pp7{"Elena"};
reseau2::Personne pp8{"Baptiste"};
reseau2::Personne pp9{"Franck"};
reseau2::Personne pp10{"Agathe"};
reseau2::Personne pp11{"Louna"};
reseau2::Personne pp12{"Theo"};
reseau2::Personne pp13{"Morgane"};
reseau2::Personne pp14{"Thibault"};
reseau2::Personne pp15{"Gwen"};
pp1.ajtContact(pp2);
pp1.ajtContact(pp5);
pp1.ajtContact(pp4);
pp3.ajtContact(pp1);
pp3.ajtContact(pp2);
pp4.ajtContact(pp5);
pp4.ajtContact(pp6);
pp5.ajtContact(pp4);
pp6.ajtContact(pp7);
pp6.ajtContact(pp9);
pp7.ajtContact(pp3);
pp8.ajtContact(pp2);
pp9.ajtContact(pp6);
pp9.ajtContact(pp11);
pp10.ajtContact(pp7);
pp10.ajtContact(pp8);
pp11.ajtContact(pp15);
pp12.ajtContact(pp10);
pp13.ajtContact(pp11);
pp14.ajtContact(pp12);
pp14.ajtContact(pp13);
pp15.ajtContact(pp9);
vector<reseau::Contact> Repertoire {c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15};
vector<reseau2::Personne> Repertoire2 {pp1, pp2, pp3, pp4, pp5, pp6, pp7, pp8, pp9, pp10, pp11, pp12, pp13, pp14, pp15};
/*
Début du menu et initialisation des variables qu'on utilisera pour chaque partie de celui-ci
*/
int choix, choix2, choix3, persChoix, persDest, persEnvoie;
cout <<"\n ---------------------------------------------------------------\n | Technique n°1 (1) | Technique n°3 (2) | Sortir (3) |\n ---------------------------------------------------------------\n\n--> ";
cin >> choix;
switch(choix) {
case 1 :
cout << "\n -------------------------------------------------------------\n | Cas global (1) | Cas individuel (2) | Retour (3) |\n -------------------------------------------------------------\n\n--> ";
cin >> choix2;
switch(choix2) {
/*
Le cas 1 et le cas 2 feront le même code au début donc on appliquera leurs différences plus tard dans un if
*/
case 1:
case 2:
cout <<"\n -------------------------------------------------------------------\n | Contact Direct (1) | Contact Indirect (2) | Retour (3) |\n -------------------------------------------------------------------\n\n--> ";
cin >> choix3;
switch(choix3) {
/*
Le cas 1 et le cas 2 feront le même code au début donc on appliquera leurs différences plus tard dans un autre switch
*/
case 1:
case 2:
/*
On applique en fonction de notre choix2 les méthodes et l'affichage voulu, afin d'éviter des répétitions dans les case.
*/
if(choix2==2){
cout << "\n Choisissez la personne que vous voulez regarder : \n\n--------------------\n(1)\tBob\n(2)\tDomi\n(3)\tAnne\n(4)\tElie\n(5)\tCali\n(6)\tSamuel\n(7)\tElena\n(8)\tBaptiste\n(9)\tFranck\n(10)\tAgathe\n(11)\tLouna\n(12)\tTheo\n(13)\tMorgane\n(14)\tThibault\n(15)\tGwen\n--------------------\n\n Tapez le numéro de la personne : ";
cin >> persChoix ;
cout << "\n";
/*
On applique en fonction de notre choix3 les méthodes voulu, afin d'éviter des répétitions dans les case.
*/
switch(choix3) {
case 1:
/*
En fonction de la personne choisi avec la variable persChoix, il affiche ses contacts directs
*/
Repertoire[persChoix-1].afficherContactDirect();
break;
case 2:
/*
En fonction de la personne choisi avec la variable persChoix, il affiche sa propagation
*/
Repertoire[persChoix-1].afficherContactIndirect(Contacts);
break;
default:
cout<<"Erreur : Tapez un nombre correct\n";
exit(0);
}
}
else{
switch(choix3){
case 1:
/*
On affiche les contacts directs de tout le réseau
*/
for (long unsigned int i=0; i<Repertoire.size(); i++){
Repertoire[i].afficherContactDirect();
}
break;
case 2:
/*
On affiche la propagation de tout le réseau
*/
for (long unsigned int i=0; i<Repertoire.size(); i++){
Repertoire[i].afficherContactIndirect(Contacts);
}
break;
default:
cout<<"Erreur : Tapez un nombre correct\n";
exit(0);
}
}
break;
case 3:
/*
les deux prochains case sont là pour appeler récursivement le main et donc notre menu
*/
main();
break;
default:
cout<<"Erreur : Tapez un nombre correct\n";
exit(0);
}
break;
case 3:
main();
break;
default:
cout<<"Erreur : Tapez un nombre correct\n";
exit(0);
}
/*
On attend 8 secondes après l'affichage de nos commandes puis on effache tout, pour avoir un ternimal vide entre chaque utilisation
*/
main();
break;
case 2 :
cout << "\n Choisissez la personne qui envoie : \n\n--------------------\n(1)\tBob\n(2)\tDomi\n(3)\tAnne\n(4)\tElie\n(5)\tCali\n(6)\tSamuel\n(7)\tElena\n(8)\tBaptiste\n(9)\tFranck\n(10)\tAgathe\n(11)\tLouna\n(12)\tTheo\n(13)\tMorgane\n(14)\tThibault\n(15)\tGwen\n--------------------\n\n Tapez le numéro de la personne : ";
cin >> persEnvoie;
cout << "\n";
cout << "\n Choisissez le destinataire : \n\n--------------------\n(1)\tBob\n(2)\tDomi\n(3)\tAnne\n(4)\tElie\n(5)\tCali\n(6)\tSamuel\n(7)\tElena\n(8)\tBaptiste\n(9)\tFranck\n(10)\tAgathe\n(11)\tLouna\n(12)\tTheo\n(13)\tMorgane\n(14)\tThibault\n(15)\tGwen\n--------------------\n\n Tapez le numéro de la personne : ";
cin >> persDest;
cout<<"test";
cout << "\n";
//Personne f= Repertoire2[persEnvoie-1]
Repertoire2[persEnvoie-1].peutCommuniquerA(Repertoire2[persDest-1]);
main();
break;
case 3 :
/* le return sert pour arrêter le programme lorsqu'on demande l'exit sur le premier menu*/
exit(0); /* */
break;
default:
cout<<"Erreur, tapez un chiffre correct\n";
exit(0);
}
int main(){
Personne p1{"Bernard","Tapie","0612345701"};
Personne p2{"Lionel","Pessi","0608345702"};
Personne p3{"Pristiano","Penaldo","0620345703"};
Personne p4{"Léon","Blum","0635345704"};
Personne p5{"Karim","Benzema","0648345705"};
Personne p6{"Jean-Pierre","Pernault","0655345706"};
Personne p7{"Johnny","Hallyday","0664345707"};
Personne p8{"Jahseh-Dwayne ","Ricardo","0670345708"};
}

Loading…
Cancel
Save