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
|
class TwoDayPackage : public Package
{
private:
double two_day_delivery_fee;
public:
TwoDayPackage(string sender_n, string sender_addr, string
sender_c, string sender_s, string sender_Z, string recipient_n,
string recipient_addr, string recipient_c, string recipient_s,
string recipient_Z, double wei, double cost, double delivery_fee);
double gettwo_day_delivery_fee();
void settwo_day_delivery_fee(double delivery_fee);
double calculateCost();
};
TwoDayPackage::TwoDayPackage(string sender_n, string sender_addr,
string sender_c, string sender_s, string sender_Z, string recipient_n,
string recipient_addr, string recipient_c, string recipient_s,
string recipient_Z, double wei, double cost, double delivery_fee)
:Package(sender_n, sender_addr, sender_c, sender_s, sender_Z, recipient_n,
recipient_addr, recipient_c, recipient_s, recipient_Z, wei, cost)
{
settwo_day_delivery_fee(delivery_fee);
}
double TwoDayPackage::gettwo_day_delivery_fee()
{
return two_day_delivery_fee;
}
void TwoDayPackage::settwo_day_delivery_fee(double delivery_fee)
{
two_day_delivery_fee = delivery_fee;
}
double TwoDayPackage::calculateCost()
{
double result;
result = Package::calculateCost() + two_day_delivery_fee;
return result;
}
class OvernightPackage : public Package
{
private:
double overnight_delivery_fee;
public:
OvernightPackage(string sender_n, string sender_addr, string sender_c,
string sender_s, string sender_Z, string recipient_n, string recipient_addr,
string recipient_c, string recipient_s, string recipient_Z, double wei,
double cost, double delivery_fee);
double calculateCost();
double getovernight_delivery_fee();
void setovernight_delivery_fee(double delivery_fee);
};
OvernightPackage::OvernightPackage(string sender_n, string sender_addr,
string sender_c, string sender_s, string sender_Z, string recipient_n,
string recipient_addr, string recipient_c, string recipient_s,
string recipient_Z, double wei, double cost, double delivery_fee)
:Package(sender_n, sender_addr, sender_c, sender_s, sender_Z, recipient_n,
recipient_addr, recipient_c, recipient_s, recipient_Z, wei, cost)
{
setovernight_delivery_fee(delivery_fee);
}
double OvernightPackage::getovernight_delivery_fee()
{
return overnight_delivery_fee;
}
void OvernightPackage::setovernight_delivery_fee(double delivery_fee)
{
overnight_delivery_fee = delivery_fee;
}
double OvernightPackage::calculateCost()
{
double result;
result = (getcostperounce() + overnight_delivery_fee) * getweight();
return result;
}
int main(int argc, char *argv[])
{
OvernightPackage item1("Jaime Lannister", "Penn 1800 St", "King's Landing",
"Knowhere", "09500", "Tyrion Lannister", "123 AAA street", "Harlem", "Cali",
"56789", 14.00, 1.50, 1.10);
TwoDayPackage item2("Jon Snow", "123 5th Street", "Hunting Pot",
"California", "12556", "Tony Stark", "455 Hawk Street", "Orlando", "Florida",
"88865", 22.00, 1.50, 8.00);
cout << fixed << setprecision(2);
cout << "--------------------------------------\n";
cout << "Overnight Delivery\n";
cout << "Sender " << item1.getsender_name() << "\n";
cout << " " << item1.getsender_address() << "\n";
cout << " " << item1.getSendCity() << " " <<
item1.getsender_state() << " " << item1.getsender_ZIP() << "\n";
cout << "\n";
cout << "Recipient " << item1.getrecipient_name() << "\n";
cout << " " << item1.getsender_address() << "\n";
cout << " " << item1.getrecipient_city() << " " <<
item1.getrecipient_state() << " " << item1.getrecipient_ZIP() << "\n";
cout << "Cost $ " << item1.calculateCost() << "\n";
cout << "--------------------------------------\n";
cout << "\n\n";
cout << "--------------------------------------\n";
cout << "2 Day Delivery\n";
cout << "Sender " << item2.getsender_name() << "\n";
cout << " " << item2.getsender_address() << "\n";
cout << " " << item2.getSendCity() << " " <<
item2.getsender_state() << " " << item2.getsender_ZIP() << "\n";
cout << "\n";
cout << "Recipient " << item2.getrecipient_name() << "\n";
cout << " " << item2.getsender_address() << "\n";
cout << " " << item2.getrecipient_city() << " " <<
item2.getrecipient_state() << " " << item2.getrecipient_ZIP() << "\n";
cout << "Cost $ " << item2.calculateCost() << "\n";
cout << "--------------------------------------\n";
return 0;
}
|