-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTransportT3.cpp
86 lines (70 loc) · 2.3 KB
/
TransportT3.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "TransportT3.h" // class implemented
using namespace std;
// File scope starts here
/////////////////////////////// PUBLIC ///////////////////////////////////////
//============================= LIFECYCLE ====================================
// Transport Default+Overloaded Constructor
Transport::Transport(int aWeight, int aCapacity, int aSpeed) : mWeight(aWeight), mCapacity(aCapacity), mSpeed(aSpeed) {
this->SetTransport(aWeight, aCapacity, aSpeed);
}
// end Transport constructor
//============================= OPERATIONS ===================================
// function that carries goods
void Transport::CarryGoods() { }
//============================= ACESS ===================================
// function that sets Weight
void Transport::SetWeight(int aWeight) {
if (aWeight < 0)
cout << "Error: Cannot set a negative weight." << endl;
else
mWeight = aWeight;
}
// end function SetWeight
// function that sets Capacity
void Transport::SetCapacity(int aCapacity) {
if (aCapacity < 0)
cout << "Error: Cannot set a negative capacity." << endl;
else
mCapacity = aCapacity;
}
// end function SetCapacity
// function that sets Speed
void Transport::SetSpeed(int aSpeed) {
if (aSpeed < 0)
cout << "Error: Cannot set a negative speed." << endl;
else
mSpeed = aSpeed;
}
// end function SetSpeed
// function that sets Transport
void Transport::SetTransport(int aWeight, int aCapacity, int aSpeed) {
this->SetWeight(aWeight);
this->SetCapacity(aCapacity);
this->SetSpeed(aSpeed);
}
// end function SetTransport
// Overloaded function that sets Transport
void Transport::SetTransport(const Transport& aTransport){
this->SetTransport(aTransport.GetWeight(), aTransport.GetCapacity(), aTransport.GetSpeed());
}
// end function SetTransport
// function that gets Weight
int Transport::GetWeight() const {
return this->mWeight;
}
// end function GetWeight
// function that gets Capacity
int Transport::GetCapacity() const {
return this->mCapacity;
}
// end function GetCapacity
// function that gets Speed
int Transport::GetSpeed() const {
return this->mSpeed;
}
// end function GetSpeed
// function that gets the Transport
const Transport& Transport::GetTransport()const {
return *this;
}
// end function GetTransport