-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVehicleBase.cpp
More file actions
65 lines (53 loc) · 1.8 KB
/
Copy pathVehicleBase.cpp
File metadata and controls
65 lines (53 loc) · 1.8 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
#ifndef __VEHICLE_BASE_CPP__
#define __VEHICLE_BASE_CPP__
#include "VehicleBase.h"
int VehicleBase::vehicleCount = 0;
// constructor
VehicleBase::VehicleBase(VehicleType type, Direction direction)
: vehicleID(VehicleBase::vehicleCount++),
vehicleType(type),
vehicleDirection(direction)
{}
//copy constructor
VehicleBase::VehicleBase(const VehicleBase& other)
: vehicleID(other.vehicleID),
vehicleType(other.vehicleType),
vehicleDirection(other.vehicleDirection)
{}
// Copy Assignment
VehicleBase& VehicleBase::operator=(const VehicleBase& other){
if (this == &other){
return *this;
}
vehicleID = other.vehicleID;
vehicleType = other.vehicleType;
vehicleDirection = other.vehicleDirection;
return *this;
}
// Move Constructor
VehicleBase::VehicleBase(VehicleBase&& other) noexcept
: vehicleID(other.vehicleID),
vehicleType(other.vehicleType),
vehicleDirection(other.vehicleDirection){
other.vehicleID = -1;
other.vehicleType = VehicleType::noType;
other.vehicleDirection = Direction::noDirection;
}
// Move Assignment
VehicleBase& VehicleBase::operator=(VehicleBase&& other) noexcept {
if (this == &other){
return *this;
}
vehicleID = other.vehicleID;
vehicleType = other.vehicleType;
vehicleDirection = other.vehicleDirection;
other.vehicleID = -1;
other.vehicleType = VehicleType::noType;
other.vehicleDirection = Direction::noDirection;
return *this;
}
VehicleBase::~VehicleBase() {}
void VehicleBase::moveForward(vector<VehicleBase*> &road, int ticksTillRed){}
void VehicleBase::moveRight(vector<VehicleBase*> &road1, vector<VehicleBase*> &road2){}
IntendedDirection VehicleBase::getVehicleIntendedDirection() const { return IntendedDirection::noDirection; }
#endif