Package inheritance hierarchy program, JAVA Programming

(Package Inheritance Hierarchy) Package-delivery services, such as FedEx®, DHL® and UPS®, offer a number of different shipping options, each with specific costs associated. Create an inheritance hierarchy to represent various types of packages. UsePackage as the base class of the hierarchy, then include classes TwoDayPackage and OvernightPackage that derive fromPackage. Base class Package should include the name, address, city, state and zip code for the package's sender and recipient, and instance variables that store the weight (in ounces) and cost per ounce to ship the package. Package's constructor should initialize these private instance variables with public properties. Ensure that the weight and cost per ounce contain positive values. Package should provide a public method CalculateCost that returns a decimal indicating the cost associated with shipping the package. Package's CalculateCost method should determine the cost by multiplying the weight by the cost per ounce. Derived class TwoDayPackage should inherit the functionality of base class Package, but also include an instance variable that represents a flat fee the shipping company charges for two-day delivery service. TwoDayPackage's constructor should receive a value to initialize this instance variable. TwoDayPackage should redefine method CalculateCost so that it computes the shipping cost by adding the flat fee to the weight-based cost calculated by base class Package's CalculateCost method. ClassOvernightPackage should inherit directly from class Package and contain an instance variable representing an additional fee per ounce charged for overnight delivery service. OvernightPackage should redefine method CalculateCost so that it adds the additional fee per ounce to the standard cost per ounce before calculating the shipping cost. Write a test application that creates objects of each type of Package and tests method CalculateCost.

Posted Date: 3/29/2013 2:18:45 AM | Location : United States

Related Discussions:- Package inheritance hierarchy program, Assignment Help, Ask Question on Package inheritance hierarchy program, Get Answer, Expert's Help, Package inheritance hierarchy program Discussions

Write discussion on Package inheritance hierarchy program
Your posts are moderated
Related Questions
Project Description: Give a script that will produce a pop-under on a mobile landing page -We can host our own landing page and we will want to change the destination URL for

Describe about the term Access Protection ? Global variables are a typical cause of bugs in most programming languages. A few unknown function can modify the value of a variabl

A joinpoint is a point in the implementation of the application where an aspect can be plugged in. This point could be a method being called, an exception being thrown, or even a f

Question: (a) Describe what is meant by a ‘constructor' in Java. Use a simple example to illustrate your answer. (b) Differentiate between a class method and an instance me

Describe the final keyword ? The final keyword is used in various different contexts as a modifier meaning in which what it modifies cannot be changed in a few sense. final c

What is an Iterator? Some of the collection classes give traversal of their contents via a java.util.Iterator interface. This interface permits you to walk through a collection

write a program that count the number of occurences of string in the n-th padovan string p(n)   program in java // aakash , suraj , prem sasi kumar kamaraj college progr

program for syntax tree

Write a program of else statement in java? The else statement in Java // This is the Hello program in Java class Hello { public static void main (String args[]) { if (