-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDriver.cpp
More file actions
231 lines (203 loc) · 4.28 KB
/
Driver.cpp
File metadata and controls
231 lines (203 loc) · 4.28 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
//
// Created by moran on 28/11/16.
//
#include "Driver.h"
/**
* constractor of driver.
* @param map1 map of the city.
* @param driverId1 driver id.
* @param age1 age of driver.
* @param status1 current trip of driver.
* @param expYears1 years of experience.
* @param avgRate1 avrage rate of passengers.
* @param taxiCab1 taxi cab.
* @return nothing.
*/
Driver::Driver(int driverId1, int age1, Status status1, int expYears1, int cabId1) {
driverId = driverId1;
age = age1;
status = status1;
expYears = expYears1;
avgRate = 0;
cabId = cabId1;
numOfDrives = 0;
currentLocation = new Point(0, 0);
available = true;
cab = NULL;
}
Driver::Driver() {
// driverId = 0;
// age = 0;
// status = Status(0);
// expYears = 0;
// avgRate = 0;
// cabId = 0;
// numOfDrives = 0;
// currentLocation = new Point(0, 0);
// available = true;
// cab = NULL;
}
/**
* destructor.
*/
Driver::~Driver() {
delete (currentLocation);
}
/**
* get driver id.
* @return driver id.
*/
int Driver::getDriverId() {
return this->driverId;
}
/**
* get driver age
* @return driver age
*/
int Driver::getAge() {
return this->age;
}
/**
* get status.
* @return status
*/
Status Driver::getStatus() {
return this->status;
}
/**
* get experience years of driver.
* @return exprience of driver.
*/
int Driver::getExpYears() {
return this->expYears;
}
/**
* get average rate of passengers.
* @return average rate of passengers.
*/
double Driver::getAvgRate() {
return this->avgRate;
}
/**
* get the current location of the driver
* @return the location
*/
const Point *Driver::getCurrentLocation() const {
return this->currentLocation;
}
/**
* access.
* @return the cab
*/
Cab *Driver::getCab() const {
return cab;
}
/**
* access.
* @return the cabId
*/
int Driver::getCabId() const {
return cabId;
}
/**
* get true if the driver acailable to trip, false if has trip.
* @return true if the driver acailable to trip, false if has trip.
*/
bool Driver::isAvailable() {
return this->available;
}
/**
* set the right cab to this driver
* @param cab the rigt cab
*/
void Driver::setCab(Cab *cab) {
this->cab = cab;
}
/**
* set current location of driver.
* @param location driver location
*/
void Driver::setCurrLocation(Point *location) {
delete (currentLocation);
this->currentLocation = new Point(location->getX(), location->getY());
}
/**
* set availability of driver.
* @param isAvailable true if available, false if not available.
*/
void Driver::setAvailable(bool isAvailable) {
this->available = isAvailable;
}
/**
* set driver id.
* @param driverId1 driver id
*/
void Driver::setDriverId(int driverId1) {
this->driverId = driverId1;
}
/**
* set driver age.
* @param age1 driver age
*/
void Driver::setAge(int age1) {
this->age = age1;
}
/**
* set status of driver.
* @param status1 status of driver.
*/
void Driver::setStatus(Status status1) {
this->status = status1;
}
/**
* set driver's years of experienes.
* @param expYears1 driver's years of experienes.
*/
void Driver::setExpYears(int expYears1) {
this->expYears = expYears1;
}
/**
* set average rate of passngers.
* @param avgRate1
*/
void Driver::setAvgRate(double avgRate1) {
this->avgRate = avgRate1;
}
/**
* set pointer to taxi cab.
* @param taxiCab1 pointer to taxi cab.
*/
void Driver::setNumOfDrives() {
this->numOfDrives = numOfDrives + 1;
}
/**
* operator == of driver
* @param driver1 the first driver
* @param driver2 the second driver
* @return if driver1 == driver2
*/
bool operator==(Driver driver1, Driver driver2) {
return (driver1.getAge() == driver2.getAge() &&
driver1.getDriverId() == driver2.getDriverId() &&
driver1.getAvgRate() == driver2.getAvgRate() &&
driver1.getExpYears() == driver2.getExpYears() &&
driver1.getStatus() == driver2.getStatus());
}
/**
* operator != of driver
* @param driver1 the first driver
* @param driver2 the second driver
* @return if driver1 != driver2
*/
bool operator!=(Driver driver1, Driver driver2) {
return !(driver1 == driver2);
}
/**
* operator overloading - print.
* @param os ostream.
* @param point point.
* @return ostream.
// */
int Driver::getNumOfDrives() {
return numOfDrives;
}