-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvehicle.cpp
52 lines (44 loc) · 1.07 KB
/
vehicle.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
#include "vehicle.h"
#include <cstdlib>
vehicle::vehicle(const int & seg_number,const unsigned int & exit_number,const bool ready)
:exit_seg(exit_number),current_seg(seg_number),ready_to_exit(ready)
{}
vehicle::vehicle(const int & seg_number,const unsigned int & exit_number)
:exit_seg(exit_number),current_seg(seg_number)
{
ready_to_exit=rand()%2 ;//[0,1]
}
void vehicle::print(const int & index)
{
cout<<"This is vehicle number #"<<index<<endl;
cout<<"ExitSegment:"<<exit_seg<<endl;
cout<<"CurrentSegment:"<<current_seg<<endl;
if(ready_to_exit)
{
cout<<"The vehicle is ready to exit"<<endl;
}
else
{
cout<<"The vehicle is NOT ready to exit"<<endl;
}
}
unsigned int vehicle::get_exit_seg()
{
return exit_seg;
}
int vehicle::get_current_seg()
{
return current_seg;
}
bool vehicle::is_ready_to_exit()
{
return ready_to_exit;
}
void vehicle::set_current_seg(const int & x)
{
current_seg=x;
}
void vehicle::set_ready_to_exit(const bool & x)
{
ready_to_exit=x;
}