-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpeopleneeds.cpp
336 lines (320 loc) · 8.78 KB
/
cpeopleneeds.cpp
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
#include "cpeopleneeds.h"
CPeopleNeeds::CPeopleNeeds()
{
productsNeed=CProducts(1,1,1);
serviceNeed=CService(1);
recreationNeed=CRecreation(1);
disturbanceNeed=1;
traffic=1;
}
CPeopleNeeds::CPeopleNeeds(CProducts _prod, CService _serv, CRecreation _rec, double _disturb, double _traffic)
{
productsNeed=_prod;
serviceNeed=_serv;
recreationNeed=_rec;
disturbanceNeed=_disturb;
traffic=_traffic;
}
CPeopleNeeds::CPeopleNeeds(const CPeopleNeeds& _C)
{
productsNeed = _C.getProductsNeed();
serviceNeed=_C.getServiceNeed();
recreationNeed = _C.getRecreationNeed();
disturbanceNeed = _C.getDisturbance();
traffic = _C.getTraffic();
}
CPeopleNeeds CPeopleNeeds::operator+ (CPeopleNeeds _C)
{
CProducts _prod(_C.getProductsNeed());
CService _serv(_C.getServiceNeed());
CRecreation _rec(_C.getRecreationNeed());
double _traffic = _C.getTraffic();
double _dist = _C.getDisturbance();
return CPeopleNeeds(productsNeed+_prod,serviceNeed+_serv,recreationNeed+_rec,disturbanceNeed+_dist,traffic+_traffic);
}
CPeopleNeeds& CPeopleNeeds::operator+= (CPeopleNeeds const &_C)
{
CProducts _prod(_C.getProductsNeed());
CService _serv(_C.getServiceNeed());
CRecreation _rec(_C.getRecreationNeed());
double _traffic = _C.getTraffic();
double _dist = _C.getDisturbance();
this->productsNeed += _prod;
this->serviceNeed +=_serv;
this->recreationNeed +=_rec;
this->disturbanceNeed +=_dist;
this->traffic +=_traffic;
return *this;
}
CPeopleNeeds& CPeopleNeeds::operator+= (CProducts const &_C)
{
productsNeed += _C;
return *this;
}
CPeopleNeeds& CPeopleNeeds::operator+= (CService const &_C)
{
serviceNeed += _C;
return *this;
}
CPeopleNeeds& CPeopleNeeds::operator+= (CRecreation const &_C)
{
recreationNeed += _C;
return *this;
}
CPeopleNeeds& CPeopleNeeds::operator=(CPeopleNeeds const &_C)
{
if(this != &_C)
{ CProducts _prod(_C.getProductsNeed());
CService _serv(_C.getServiceNeed());
CRecreation _rec(_C.getRecreationNeed());
double _traffic = _C.getTraffic();
double _dist = _C.getDisturbance();
this->productsNeed = _prod;
this->serviceNeed =_serv;
this->recreationNeed =_rec;
this->disturbanceNeed =_dist;
this->traffic =_traffic;
}
return *this;
}
CPeopleNeeds CPeopleNeeds::countNewNeeds(double _lifeSatisfaction)
{
double _food=1+0.6*_lifeSatisfaction;
double _light=0.5+1*_lifeSatisfaction;
double _heavy=0.5+0.8*_lifeSatisfaction;
double _serv1=0.5+1*_lifeSatisfaction;
double _rec1=0.5+1*_lifeSatisfaction;
double _disturbance=1+0.4*_lifeSatisfaction;
double _traffic=2+0.3*_lifeSatisfaction;
return CPeopleNeeds(CProducts(_light,_heavy,_food),CService(_serv1),CRecreation(_rec1),_traffic,_disturbance);
}
CPeopleNeeds CPeopleNeeds::countSetNewNeeds(double _lifeSatisfaction)
{
CPeopleNeeds _N(countNewNeeds(_lifeSatisfaction));
(*this) = _N;
return _N;
}
double CPeopleNeeds::countLifeSatisfation(double _income)
{
double lifeSat;
int aInc=1;
if(_income<0)
aInc=-1;
double aDist=1;
if(disturbanceNeed<0)
aDist=-1;
if(traffic<1)
traffic=1;
if(abs(disturbanceNeed)<1)
disturbanceNeed=1;
if(abs(_income)<1)
_income=1;
double _rec1=recreationNeed.getRecreation1();
if(_rec1<1)
_rec1=1;
double _food=productsNeed.getFood();
if(_food<1)
_food=1;
double _light=productsNeed.getLight();
if(_light<1)
_light=1;
double _heavy =productsNeed.getHeavy();
if(_heavy<1)
_heavy=1;
double _service=serviceNeed.getService1();
if(_service<1)
_service=1;
lifeSat = (1+0.2*(trafficInd*log10(traffic)+aDist*disturbanceInd*log10(abs(disturbanceNeed))+
recreationInd*log10(_rec1)+foodInd*log10(_food)+
lightInd*log10(_light)+heavyInd*log10(_heavy)+
serviceInd*log10(_service)+aInc*incomeInd*log10(abs(_income))));
return lifeSat;
}
double CPeopleNeeds::countLifeSatisfation(double _income, double _lifeSatPast)
{
double lifeSat=countLifeSatisfation(_income);
return (3*_lifeSatPast+lifeSat)/4;
}
void CPeopleNeeds::setAll(CProducts _prod,CService _serv,CRecreation _rec,double _traf,double _dist)
{
productsNeed = _prod;
serviceNeed=_serv;
recreationNeed=_rec;
traffic = _traf;
disturbanceNeed=_dist;
}
void CPeopleNeeds::setProductsNeed(CProducts _prod)
{ productsNeed = _prod;}
void CPeopleNeeds::setServiceNeed(CService _serv)
{ serviceNeed=_serv;}
void CPeopleNeeds::setRecreationNeed(CRecreation _rec)
{ recreationNeed=_rec;}
void CPeopleNeeds::setTraffic(double _traf)
{ traffic = _traf;}
void CPeopleNeeds::setDistrurbance(double _dist)
{ disturbanceNeed=_dist;}
void CPeopleNeeds::addTraffic(double _traf)
{ traffic +=_traf;}
void CPeopleNeeds::addDisturbance(double _dist)
{ disturbanceNeed += _dist;}
CProducts CPeopleNeeds::getProductsNeed() const
{ return productsNeed;}
CService CPeopleNeeds::getServiceNeed() const
{ return serviceNeed;}
CRecreation CPeopleNeeds::getRecreationNeed() const
{ return recreationNeed;}
double CPeopleNeeds::getDisturbance() const
{ return disturbanceNeed;}
double CPeopleNeeds::getTraffic() const
{ return traffic;}
//CProducts
CProducts::CProducts()
{
lightIndustry=0;
heavyIndustry=0;
food=0;
}
CProducts::CProducts(double _light, double _heavy, double _food)
{
lightIndustry=_light;
heavyIndustry=_heavy;
food=_food;
}
CProducts::CProducts(const CProducts& _C)
{
lightIndustry=_C.getLight();
heavyIndustry=_C.getHeavy();
food=_C.getFood();
}
CProducts CProducts::operator+ (CProducts _C)
{
return CProducts(lightIndustry+_C.getLight(),heavyIndustry+_C.getHeavy(),food+_C.getFood());
}
CProducts CProducts::operator- (CProducts _C)
{ return CProducts(lightIndustry-_C.getLight(),heavyIndustry-_C.getHeavy(),food-_C.getFood());}
CProducts& CProducts::operator+= (CProducts const &_C)
{
this->lightIndustry +=_C.getLight();
this->heavyIndustry +=_C.getHeavy();
this->food +=_C.getFood();
return *this;
}
CProducts& CProducts::operator=(CProducts const &_C)
{
if(this != &_C)
{ this->lightIndustry =_C.getLight();
this->heavyIndustry =_C.getHeavy();
this->food =_C.getFood();
}
return *this;
}
bool CProducts::restoreIfNotPossitiveNONeeds()
{
bool _good = true;
if( food<0)
{ food=0;
_good=false;}
if(heavyIndustry<0)
{ heavyIndustry=0;
_good = false;}
if(lightIndustry<0)
{ lightIndustry=0;
_good= false;}
return _good;
}
double CProducts::getLight() const
{return lightIndustry;}
double CProducts::getHeavy() const
{return heavyIndustry;}
double CProducts::getFood() const
{return food;}
void CProducts::setAll(double _light, double _heavy, double _food)
{
lightIndustry=_light;
heavyIndustry=_heavy;
food=_food;
}
void CProducts::setLight(double _light)
{ lightIndustry=_light;}
void CProducts::setHeavy(double _heavy)
{ heavyIndustry=_heavy;}
void CProducts::setFood(double _food)
{ food=_food;}
//CService
CService::CService()
{
service1=0;
}
CService::CService(double _serv1)
{
service1=_serv1;
}
CService::CService(const CService& _C)
{
service1=_C.getService1();
}
CService CService::operator+ (CService _C)
{
return CService(service1+_C.getService1());
}
CService& CService::operator+= (CService const &_C)
{
this->service1 += _C.getService1();
return *this;
}
CService& CService::operator=(CService const &_C)
{
if(this != &_C)
{ this->service1 = _C.getService1();
}
return *this;
}
bool CService::restoreIfNotPossitiveNONeeds()
{
bool _good = true;
if( service1<0)
{ service1=0;
_good=false;}
return _good;
}
double CService::getService1() const
{ return service1;}
void CService::setService1(double _serv)
{ service1=_serv;}
//CRecreation
CRecreation::CRecreation()
{ recreation1=0;}
CRecreation::CRecreation(double _recr1)
{ recreation1=_recr1;}
CRecreation::CRecreation(const CRecreation& _C)
{
recreation1=_C.getRecreation1();
}
CRecreation CRecreation::operator+ (CRecreation _C)
{
return CRecreation(recreation1+_C.getRecreation1());
}
CRecreation& CRecreation::operator+= (CRecreation const &_C)
{
this->recreation1 +=_C.getRecreation1();
return *this;
}
CRecreation& CRecreation::operator=(CRecreation const &_C)
{
if(this != &_C)
{ this->recreation1 =_C.getRecreation1();
}
return *this;
}
bool CRecreation::restoreIfNotPossitiveNONeeds()
{
bool _good = true;
if( recreation1<0)
{ recreation1=0;
_good=false;}
return _good;
}
double CRecreation::getRecreation1() const
{ return recreation1;}
void CRecreation::setRecreation1(double _rec)
{ recreation1=_rec;}