-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJunction.h
52 lines (48 loc) · 1.83 KB
/
Junction.h
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
//
// Created by RYC on 2020/4/14.
//
#ifndef TRAFFICLIGHTSYSTEM_JUNCTION_H
#define TRAFFICLIGHTSYSTEM_JUNCTION_H
#include "Road.h"
#include "PedestrianLight.h"
//class containing attributes and methods associated with a junction
class Junction {
public:
//constructor - no data provided
Junction();
//constructor for cross junction - data provided
Junction(int, int, string);
//constructor for T Junction - data provided
Junction(int, int, string, char);
//contains four roads (with single direction and one traffic light)
~Junction();
vector<Road> roadSeq = {
Road('n', 50, 5),
Road('e', 50, 5),
Road('s', 50, 5),
Road('w', 50, 5)
};
//execute light sequence functionality simultaneously with junction functionality
thread simulate_one_tick();
//iterates through roads that make up junction
//initially points to the south road in the north direction (moving clockwise afterwards)
vector<Road>::iterator currentRoad = roadSeq.begin();
//each junction contains one pedestrian light
//instance created with associated delay of 8 seconds for green state
PedestrianLight* pedestrianLight = new PedestrianLight(8);
//method to simulate one complete junction
void tick();
string name;
//method to set traffic lights to work independently
void generateIndepSeq();
//connects adjacent junctions in grid to the four roads of the current junction
void setCloseJunctions(Junction*, Junction*, Junction*, Junction*);
//pointers to the adjacent junctions
Junction *westJunction = nullptr;
Junction *eastJunction = nullptr;
Junction *northJunction = nullptr;
Junction *southJunction = nullptr;
//variables associated with central point of junction
int ctr_x = 100, ctr_y = 100;
};
#endif //TRAFFICLIGHTSYSTEM_JUNCTION_H