-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUser.cpp
66 lines (55 loc) · 1.47 KB
/
User.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "User.h"
//required for inputtig and outputting data
#include <iostream>
using namespace std;
//function definition for constructor - no data provided
User::User() {
//initialises start point to predefined position
setPt(0, 0);
}
//function definiton for adding more cars to the road
User User::operator+(User a) {
//create new instance of User class
User c;
//Increase number of cars
c.NumOfCars = this->NumOfCars + a.NumOfCars;
return c;
}
//function definiton for adding more cars to the road
User User::operator-(User a) {
//create new instance of User class
User c;
//decrease number of cars
c.NumOfCars = this->NumOfCars - a.NumOfCars;
return c;
}
//function definiton for stopping user movement
void User::stop() {
setVelocity(0);
}
//function definiton for starting user movement
void User::start() {
//the velocity is set to a constant speed
setVelocity(speed);
}
//function definiton for setting the user's velocity
void User::setVelocity(int velocity) {
this->velocity = velocity;
}
//function definiton for setting user's position on the map
void User::setPt(int x, int y) {
this->x = x;
this->y = y;
}
//function definiton for returning user's speed
int User::getSpeed() {
return speed;
}
//function definiton for setting user's speed
void User::setSpeed(int speed) {
this->speed = speed;
}
//function definiton for returning user's velocity
int User::getVelocity() {
return velocity;
}