-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPedestrianLight.cpp
37 lines (32 loc) · 967 Bytes
/
PedestrianLight.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
//
// Created by RYC on 2020/4/26.
//
//Windows.h required for sleep functionality
#include "Windows.h"
#include "pedestrianLight.h"
//function definition for constructor - no data provided
PedestrianLight::PedestrianLight() {
//predefined delays utilised
setDelays(this->period);
}
//function definition for constructor - data provided
PedestrianLight::PedestrianLight(int period) {
//user defined delays utilised
setDelays(period);
}
//function definition for delay of green state
void PedestrianLight::setDelays(int period) {
this->period = period;
}
//function definition for one light sequence
void PedestrianLight::run_one_cycle() {
//pedestrain can cross while current time is less than period of green state
canPass = true;
int count = 0;
while(count < period){
//sleep used to generate 1 second time interval between each iteration of count
Sleep(1000);
count++;
}
canPass = false;
}