Code:OvernitPackage.cpp #include "OvernitPackage.h" OvernitPackage::OvernitPackage(string SF, string RF, string SAD,string RAD, string SCT, string SST, int SZP,string RCT, string RST, int RZP,double CS,double W, double CO,double OverR):Package( SF,RF,SAD,RAD,SCT,SST,SZP,RCT,RST,RZP,CS,W,CO) { SetOvernitRate(OverR); } OvernitPackage::~OvernitPackage() { } void OvernitPackage::SetOvernitRate(double OverR) { OvernitRate=OverR; } double OvernitPackage::GetOvernitRate() { return OvernitRate; } void OvernitPackage::calculateCost(double CS, double W, double CO, double OverR) { if ( CO>=0 && W>=0) { CS=(CO+OverR)*W; } } double OvernitPackage::GetcalculateCost() { return Cost; } OvernitPackage.h #ifndef OVERNITPACKAGE_H #define OVERNITPACKAGE_H #include <string> #include <iostream> using namespace std; #include "Package.h" class OvernitPackage : public Package { public: OvernitPackage(string SF, string RF, string SAD,string RAD, string SCT, string SST,int SZP,string RCT, string RST, int RZP,double CS,double W, double CO,double OverR); ~OvernitPackage(); void SetOvernitRate(double OverR); double GetOvernitRate(); void calculateCost(double CS,double W, double CO, double OverR); double GetcalculateCost(); private: double OvernitRate; double Weight; double CostPerOunce; double Cost; }; #endif Package.cpp #include "Package.h" Package::Package(string SF, string RF, string SAD,string RAD, string SCT, string SST, int SZP,string RCT, string RST, int RZP,double CS,double W, double CO) { SetSenderName(SF); SetRecipientName(RF); SetSenderAddress(SAD); SetRecipientAddress(RAD); SetSenderCity(SCT); SetSenderState(SST); SetSenderZipCode(SZP); SetRecipientCity(RCT); SetRecipientState(RST); SetRecipientZipCode(RZP); calculateCost(CS, W, CO); GetcalculateCost(); } Package::~Package() { } void Package::SetSenderName(string SF) { cout<<"What is sender's name?"<<endl; Sender=SF; } string Package::GetSenderName() { return Sender; } void Package::SetSenderAddress(string SAD) { //cout<<"Where is this mail sent from?"<<endl; SenderAddress=SAD; } string Package::GetSenderAddress() { return SenderAddress; } void Package::SetSenderCity(string SCT) { //cout<<"City of sender:"<<endl; SenderCtiy=SCT; } string Package::GetSenderCity() { return SenderCtiy; } void Package::SetSenderState(string SST) { //cout<<"State of sender:"<<endl; SenderState=SST; } string Package::GetSenderState() { return SenderState; } void Package::SetSenderZipCode(int SZP) { //cout<<"Zip Code of sender:"<<endl; SenderZip=SZP; } int Package::GetSenderZipCode() { return SenderZip; } void Package::SetRecipientName(string RF) { //cout<<"What is recipient's name?"<<endl; Recipient=RF; } string Package::GetRecipientName() { return Recipient; } void Package::SetRecipientAddress(string RAD) { //cout<<"Where is this mail going to ?"<<endl; RecipitientAddress=RAD; } string Package::GetRecipientAddress() { return RecipitientAddress; } void Package::SetRecipientCity(string RCT) { //cout<<"City of recipient:"<<endl; RecipientCtiy=RCT; } string Package::GetRecipientCity() { return RecipientCtiy; } void Package::SetRecipientState(string RST) { //cout<<"State of sender:"<<endl; RecipientState=RST; } string Package::GetRecipientState() { return RecipientState; } void Package::SetRecipientZipCode(int RZP) { //cout<<"Zip Code of Recipient:"<<endl; RecipientZip=RZP; } int Package::GetRecipientZipCode() { return RecipientZip; } void Package::calculateCost(double CS, double W, double CO) { if ( CO>=0 && W>=0) { CS=CO*W; } } double Package::GetcalculateCost() { return Cost; } Package.h #ifndef PACKAGE_H #define PACKAGE_H #include <string> #include <iostream> using namespace std; class Package { public: Package( string SF, string RF, string SAD,string RAD, string SCT, string SST,int SZP,string RCT, string RST, int RZP,double CS,double W, double CO); ~Package(); void SetSenderName(string SF); string GetSenderName(); void SetRecipientName(string RF); string GetRecipientName(); void SetSenderAddress(string SAD); string GetSenderAddress(); void SetRecipientAddress(string RAD); string GetRecipientAddress(); void SetSenderCity(string SCT); string GetSenderCity(); void SetSenderState(string SST); string GetSenderState(); void SetSenderZipCode(int SZP); int GetSenderZipCode(); void SetRecipientCity(string RCT); string GetRecipientCity(); void SetRecipientState(string RST); string GetRecipientState(); void SetRecipientZipCode(int RZP); int GetRecipientZipCode(); void calculateCost( double CS,double W, double CO); double GetcalculateCost(); private: string Sender; string Recipient; string SenderAddress; string RecipitientAddress; string SenderCtiy; string SenderState; string RecipientCtiy; string RecipientState; int RecipientZip; int SenderZip; double Weight; double CostPerOunce; double Cost; }; #endif test.h #include "Package.h" #include "OvernitPackage.h" #include "TwoDayPackage.h" void main() { TwoDayPackage P; P.SetSenderName(""); } TwoDayPackage.cpp #include "TwoDayPackage.h" TwoDayPackage::TwoDayPackage(string SF, string RF, string SAD,string RAD, string SCT, string SST,int SZP,string RCT, string RST, int RZP,double CS,double W, double CO,double FF):Package(SF,RF,SAD,RAD,SCT,SST,SZP,RCT,RST,RZP,CS,W,CO) { SetFlatFee(FF); } TwoDayPackage::~TwoDayPackage() { } void TwoDayPackage::SetFlatFee(double FF) { FlatFee=FF; } double TwoDayPackage::GetFlatFee() { return FlatFee; } void TwoDayPackage::calculateCost(double CS, double W, double CO, double FF ) { if ( CO>=0 && W>=0) { CS=CO*W+FF; } } double TwoDayPackage::GetcalculateCost() { return Cost; } TwoDayPackage.h #ifndef TWODAYPACKAGE_H #define TWODAYPACKAGE_H #include <string> #include <iostream> using namespace std; #include "Package.h" class TwoDayPackage : public Package { public: TwoDayPackage( string SF, string RF, string SAD,string RAD, string SCT, string SST,int SZP,string RCT, string RST, int RZP,double CS,double W, double CO, double FF); ~TwoDayPackage(); void SetFlatFee(double FF); double GetFlatFee(); void calculateCost(double CS,double W, double CO, double FF); double GetcalculateCost(); private: double FlatFee; double Weight; double CostPerOunce; double Cost; }; #endif