-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompany_User.cpp
More file actions
60 lines (46 loc) · 1.69 KB
/
Company_User.cpp
File metadata and controls
60 lines (46 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// Created by Utente on 28/05/2018.
//
#include "Company_User.h"
#include <algorithm>
Company_User::Company_User(const string &ID, const string &name, const Date &date, const Address &address,const string &product)
:User(ID,name,date,address){
_product = product;
}
Company_User::~Company_User() {
}
//---------------SETTERS-------------
void Company_User::setProduct(const string &product) {
_product = product;
}
//---------------GETTERS---------------
string Company_User::getProduct() {
return _product;
}
//----------------COUNTERS----------------
int Company_User::countEmployees(Graph<User*,string,string> &grafo) {
int cont=0;
//prendo la mappa delle relazioni di un utente
map<string,vector<string>> relationships_map = grafo.getEdges(_ID);
//scorro la mappa
for(map<string,vector<string>>::iterator it = relationships_map.begin(); it != relationships_map.end(); it++){
//se trovo una relazione di dipendente incremento il contatore
if(find((it->second).begin(), (it->second).end(), "dipendente") != (it->second).end() ) {
cont++;
}
}
return cont;
}
int Company_User::countPartners(Graph<User*,string,string> &grafo) {
int cont=0;
//prendo la mappa delle relazioni di un utente
map<string,vector<string>> relationships_map = grafo.getEdges(_ID);
//scorro la mappa
for(map<string,vector<string>>::iterator it = relationships_map.begin(); it != relationships_map.end(); it++){
//se trovo una relazione di dipendente incremento il contatore
if(find((it->second).begin(), (it->second).end(), "consociata") != (it->second).end() ) {
cont++;
}
}
return cont;
}