Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, please help me with questions a), b) and c). Please use C++. Will rate. Thanks. C +Programming Question: Polymorphism Package packageID : int nameRecipent

Hi, please help me with questions a), b) and c). Please use C++. Will rate. Thanks.image text in transcribed

image text in transcribed

C +Programming Question: Polymorphism Package packageID : int nameRecipent : string a addressRecipent: string a deliveryDate: Date a hasBeenDelivered: bool a weight: double rate : double o count: int e Package(int, string, string, double, double) : double OvernightPackage TwoDayPackage a flatFee: double a additionalFee: double OvernightPackageint, string, string, double, double, double) TwoDayPackage(int, string, string, double, double, double) double In order to calculate the shipping cost for an individual package, the various package classes of question 1 shall be extended by the following public member function double calculateCost () The function returns a double indicating the shipping costs of the package a) Provide specifications (.h file) and if needed implementations (.cpp file) of calculateCost )for the classes Package, TwoDayPackage, and OvernightPackage. The cost calculations are performed as follows: [6 marks] Class Package TwoDayPackage OvernightPackage weight (rate+ additionalFee) Cost Calculation Abstract (pure virtual) weight rate +flatFee The code snippet below defines a global array of pointers to objects that derive from the Package base class. #include #include #include #include "overnigh tPackage.h" "twoDayPackage.h" using namespace std; const int arraySize100; Package packageArray [arraySize] int main ) i //The code for question 2b should fit in here b) Provide an implementation of the main function fulfilling the following tasks: Initialize the elements of packageArray to NULL (0) pointers. Dynamically create some objects of the OvernightPackage and TwoDayPackage classes and insert their addresses into packageArray. The address of an object has to be inserted at the first available position from the beginning. [6 marks] c) Provide the implementation of a function with the following prototype: bool deliverPackage (int id) The function will find the package with the corresponding id and will change the value of its member variable hasBeenDelivered to true. If the package cannot be found, the function returns false, otherwise true. [8 marks]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Presentation Aids Practicing Your Speech?

Answered: 1 week ago