-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackage.cpp
More file actions
132 lines (117 loc) · 2.76 KB
/
Package.cpp
File metadata and controls
132 lines (117 loc) · 2.76 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
#include "Package.h"
Package::Package
(const std::string& _sName, const std::string& _sAddress, const std::string& _sCity, const std::string& _sProvince, const std::string& _sPostalCode, // sender
const std::string& _rName, const std::string& _rAddress, const std::string& _rCity, const std::string& _rProvince, const std::string& _rPostalCode, // recipient
double _weight, double _costPerKilo)
:
sName(_sName), sAddress(_sAddress), sCity(_sCity), sProvince(_sProvince), sPostalCode(_sPostalCode),
rName(_rName), rAddress(_rAddress), rCity(_rCity), rProvince(_rProvince), rPostalCode(_rPostalCode)
{
setWeight(_weight);
setCostPerKilo(_costPerKilo);
}
// sender setter and getter definitions
void Package::setSenderName(const std::string& n)
{
sName = n;
}
std::string Package::getSenderName() const
{
return sName;
}
void Package::setSenderAddress(const std::string& a)
{
sAddress = a;
}
std::string Package::getSenderAddress() const
{
return sAddress;
}
void Package::setSenderCity(const std::string& c)
{
sCity = c;
}
std::string Package::getSenderCity() const
{
return sCity;
}
void Package::setSenderProvince(const std::string& p)
{
sProvince = p;
}
std::string Package::getSenderProvince() const
{
return sProvince;
}
void Package::setSenderPostalCode(const std::string& pc)
{
sPostalCode = pc;
}
std::string Package::getSenderPostalCode() const
{
return sPostalCode;
}
// recipient setter and getter definitions
void Package::setRecipientName(const std::string& n)
{
rName = n;
}
std::string Package::getRecipientName() const
{
return rName;
}
void Package::setRecipientAddress(const std::string& a)
{
rAddress = a;
}
std::string Package::getRecipientAddress() const
{
return rAddress;
}
void Package::setRecipientCity(const std::string& c)
{
rCity = c;
}
std::string Package::getRecipientCity() const
{
return rCity;
}
void Package::setRecipientProvince(const std::string& p)
{
rProvince = p;
}
std::string Package::getRecipientProvince() const
{
return rProvince;
}
void Package::setRecipientPostalCode(const std::string& pc)
{
rPostalCode = pc;
}
std::string Package::getRecipientPostalCode() const
{
return rPostalCode;
}
// member function defintions
void Package::setWeight(double w)
{
if (w < 0.0) { std::cout << "Invalid weight entry." << std::endl; weight = 0.0; }
else weight = w;
}
double Package::getWeight() const
{
return weight;
}
void Package::setCostPerKilo(double c)
{
if (c < 0.0) { std::cout << "Invalid cost entry." << std::endl; costPerKilo = 0.0; }
else costPerKilo = c;
}
double Package::getCostPerKilo() const
{
return costPerKilo;
}
double Package::calculateCost() const
{
return getWeight() * getCostPerKilo();
}