Delivery OOP Program
Description
This is an OOP program that uses PackageClass object to calculate the delivery cost for a shipping company.Each package object has three instance data members: package id, weight (in ounces) and cost per ounce to ship the package.
The PackageClass also has a static data member that represents a flat fee that the shipping company charges for each package.
The ADT (abstract data type) is PackageClass.java.
The client program is DeliveryCompany.java.
Associated Concepts:
Object Oriented Programming (OOP)
Data member: instance variable
Data member: static variable
Instance method and static method
Reserved keyword: this
Constructor
Getter and getter
toString method
Data member: static variable
Instance method and static method
Reserved keyword: this
Constructor
Getter and getter
toString method
Algorithm:
For PackageClass, the class diagram is represented in
UML (Unified Modeling Language) notation.
Client program:
Client program:
Call static method to set the static data member
Create the PackageClass object with hard-coded values
Use the object reference p1 to call the method to calculate the delivery cost
Print the object's information
Create the PackageClass object with hard-coded values
Use the object reference p1 to call the method to calculate the delivery cost
Print the object's information
Source Code
PackageClass.java Source CodeDeliveryCompany.java Source Code
Sample Run
Refer to the video in IDE page on how to use NetBeans