COMP2247 - Algorithms and Data Structures

Syllabus Software Installation Assignments Tests
Lectures and Labs
**Back to Full Menu**

OOP - Aggregation Delivery Program
Address.java
Person.java
MyDate.java
Parcel.java
DeliveryClient.java
Course Program
Book.java
Instructor.java
Student.java
MyDate.java
Course.java
CourseClient.java
Parking Ticket Program
Car.java
Officer.java
ParkingMeter.java
MyDate.java
Ticket.java
ParkingTicketClient.java




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:

Create a Parcel object

Print the Parcel object

Set the delivery data data member

Calculate the delivery cost

Print the result

Source Code

Address class



Person class



MyDate class



Parcel class



Client program



Sample Run



Video