-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectClasses.cpp
More file actions
101 lines (99 loc) · 2.02 KB
/
ObjectClasses.cpp
File metadata and controls
101 lines (99 loc) · 2.02 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
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
// Road, Vehicle, etc structes
#include <string>
#define HIGH 0
#define MEDIUM 1
#define LOW 2
using namespace std;
//Typedefining Intersection as it has single member or no method
typedef char Intersection;
struct Road
{
Intersection from;
Intersection to;
int travel_time;
string status;
bool is_closed;
Road()
{
this->from = 'a';
this->to = 'a';
travel_time = 0;
status = "Clear";
is_closed = false;
}
Road(char from, char to, int weight, string status)
{
this->from = from;
this->to = to;
travel_time = weight;
this->status = status;
if (status == "Clear")
{
is_closed = false;
}
else
{
is_closed = true;
}
}
Road(char from, char to, int weight)
{
this->from = from;
this->to = to;
travel_time = weight;
status = "Clear";
is_closed = false;
}
void changeStatus(string new_status)
{
status = new_status;
if (status == "Clear")
{
is_closed = false;
}
else
{
is_closed = true;
}
}
};
// to change Road status use changeStatus method
struct Vehicle
{
string id;
char source;
char destination;
int priority;
Vehicle(string id=0, char s='a', char d='a')
{
this->id = id;
source = s;
destination = d;
priority = LOW;
}
Vehicle(string id, char s, char d, int priority)
{
this->id = id;
source = s;
destination = d;
this->priority = priority;
}
Vehicle(string id, char s, char d, string priority)
{
this->id = id;
source = s;
destination = d;
if (priority == "High")
{
this->priority = HIGH;
}
else if (priority == "Medium")
{
this->priority = MEDIUM;
}
else
{
this->priority = LOW;
}
}
};