-
Notifications
You must be signed in to change notification settings - Fork 0
/
Entities.cpp
59 lines (45 loc) · 1.22 KB
/
Entities.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
#include "Entities.h"
Problem::Problem(){
}
void Problem::solve(){
system("echo 'execution' >> peopleThread.file");
int waitTime = (rand() % (MAX_TIME_TO_USE_BATHROOM - MIN_TIME_TO_USE_BATHROOM)) + MIN_TIME_TO_USE_BATHROOM;
usleep(waitTime*100);
}
PeopleData::PeopleData(){
avarangeTimeN = 0;
avarangeTimeEN = 0;
avaranteTimeToExecution = 0;
avaranteTimeOfExecution = 0;
}
void PeopleData::addExecutionAvarange(double time){
avaranteTimeOfExecution = avaranteTimeOfExecution*avarangeTimeN + time;
avarangeTimeN++;
avaranteTimeOfExecution = avaranteTimeOfExecution/avarangeTimeN;
}
void PeopleData::addFinishedWaitAvarange(double time){
avaranteTimeToExecution = avaranteTimeToExecution*avarangeTimeEN + time;
avarangeTimeEN++;
avaranteTimeToExecution = avaranteTimeToExecution/avarangeTimeEN;
}
void PeopleData::clearWaitingList(){
while(!waitIds.empty())
waitIds.pop_front();
}
void PeopleData::clearExecutionsList(){
while(!executionsIds.empty())
executionsIds.pop_front();
}
void PeopleData::addWaiting(int x, ulint y){
waitIds.push_back(Tupla(x, y));
}
PersonData::PersonData()
{
executionTime = 0;
waitingTime = 0;
starttime = 0;
totalWait = 0;
inExecution = false;
finished = false;
onWait = false;
}