-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindow.cpp
More file actions
59 lines (49 loc) · 1.17 KB
/
Window.cpp
File metadata and controls
59 lines (49 loc) · 1.17 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
59
#include "Window.h"
Window::Window() {
longestIdleTime = 0;
idlesOver5 = 0;
totalIdleTime = 0;
currentIdle = 0;
currentCustomer = NULL;
}
Window::~Window() {
currentCustomer = NULL;
}
void Window::timeIncrement() {
// increment time of customer
if(currentCustomer != NULL){
currentCustomer->timeIncrement();
// check if done
if (currentCustomer->needsNewQueue()){
currentCustomer = NULL;
}
}
else {
// iterate idle time if no customer
currentIdle++;
totalIdleTime++;
// update idle trackers based on time spent
if (currentIdle == 5) idlesOver5++;
if (currentIdle > longestIdleTime)
longestIdleTime = currentIdle;
}
}
// updates customer at window and idle time
void Window::approachWindow(Customer* c) {
currentCustomer = c;
currentIdle = 0;
}
// aux empty function
bool Window::isEmpty() {
return (currentCustomer == NULL);
}
/* accessors */
int Window::getLongestIdleTime() {
return longestIdleTime;
}
int Window::getNumIdlesOver5() {
return idlesOver5;
}
int Window::getTotalIdleTime() {
return totalIdleTime;
}