-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOvernightPackage.cpp
More file actions
29 lines (26 loc) · 1.13 KB
/
OvernightPackage.cpp
File metadata and controls
29 lines (26 loc) · 1.13 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
#include "OvernightPackage.h"
OvernightPackage::OvernightPackage
(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, double _flatFee)
: Package(_sName, _sAddress, _sCity, _sProvince, _sPostalCode,
_rName, _rAddress, _rCity, _rProvince, _rPostalCode,
_weight, _costPerKilo)
{
setOvernightFee(overnightFee);
}
void OvernightPackage::setOvernightFee(double f)
{
if (f < 0.0) { overnightFee = 0.0; }
else overnightFee = f;
}
double OvernightPackage::getOvernightFee() const
{
return overnightFee;
}
double OvernightPackage::calculateCost() const
{
return getWeight() * (Package::getCostPerKilo() + getOvernightFee());
// a bit confusing, but we're returning the cost per kilogram with the overnight fee (since the overnight fee is charged per kilogram)
// then we multiply that value by the overall weight
}