Delivery Program
Description
This program uses OOP aggregation (composition) concept to design classes to represent parcel object and calculate the delivery cost.Each parcel object includes data members representing the name, address, city, state and ZIP code for both the sender and the recipient, the receiving date and the delivery date. It also has the tracking number, the weight (in ounces) and the cost per ounce to ship the package.
In addition, it includes a method to calculate and return the cost to ship the parcel.
The program defines Address, Person, MyDate, and Parcel classes.
The Parcel class incorporates the aggregation technique to include the objects of Address, Person, and MyDate as data members.
Associated Concepts:
OOP - Aggregation
Algorithm:
Class diagram for a single class design without aggregation:
Class diagrams for the design with aggregation:
Client program:
Class diagrams for the design with aggregation:
Client program:
Create a Parcel object
Print the Parcel object
Set the delivery data data member
Calculate the delivery cost
Print the result
Print the Parcel object
Set the delivery data data member
Calculate the delivery cost
Print the result
Source Code
Address classPerson class
MyDate class
Parcel class
Client program