Write test program that creates objects of each type package

Assignment Help Basic Computer Science
Reference no: EM131610258

Question: (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. Use class Package as the base class of the hierarchy, then include classes Two Day Package and Over night Package that derive from Package. Base class Package should include data members representing the name, address, city, state and ZIP code for both the sender and the recipient of the package, in addition to data members that store the weight (in ounces) and cost per ounce to ship the package. Package's constructor should initialize these data members. Ensure that the weight and cost per ounce contain positive values. Package should provide a public member function calculate Cost that returns a double indicating the cost associated with shipping the package. Package's calculate Cost function should determine the cost by multiplying the weight by the cost per ounce. Derived class Two Day Package should inherit the functionality of base class Package, but also include a data member that represents a flat fee that the shipping company charges for two-day-delivery service. Two Day Package's constructor should receive a value to initialize this data member. Two Day Package should redefine member function calculate Cost so that it computes the shipping cost by adding the flat fee to the weight-based cost calculated by base class Package's calculate Cost function. Class Over night Package should inherit directly from class Package and contain an additional data member representing an additional fee per ounce charged for overnight-delivery service. Over night Package should redefine member function calculate Cost so that it adds the additional fee per ounce to the standard cost per ounce before calculating the shipping cost. Write a test program that creates objects of each type of Package and tests member function calculate Cost.

Reference no: EM131610258

Questions Cloud

How can meta-leadership enhance shortcomings : How can Meta-Leadership enhance and address the shortcomings noted in the Pentagon of Police Leadership Model
Define microscopic and macroscopic crime scenes : Discuss the terms primary and secondary crime scenes and microscopic and macroscopic crime scenes. How do these terms relate to crime scene examination
Draw an inheritance hierarchy for the given classes : (Quadrilateral Inheritance Hierarchy) Draw an inheritance hierarchy for classes Quadrilateral, Trapezoid, Parallelogram, Rectangle and Square.
Discuss about the personal key performance indicators : Using Porter's Five Forces Model, personal Critical Success Factors (CSFs) and/ personal Key Performance Indicators (KPIs).
Write test program that creates objects of each type package : (Package Inheritance Hierarchy) Package-delivery services, such as FedEx®, DHL® and UPS®, offer a number of different shipping options.
How public officers enforce the laws for private companies : How can public officers enforce the laws for private companies without creating a conflict of interest
Define the requirements of human service workers : Review your state's law or administrative rule regarding informed consent and the requirements of human service workers
Describe about the account inheritance hierarchy : Create an inheritance hierarchy that a bank might use to represent customers' bank accounts. All customers at this bank can deposit (i.e., credit).
Why are tribunals very important among two or more countries : Why are tribunals very important among two or more countries. How can the cultural and political differences that exist between nations affect a tribunal

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Great outside resources to learn programming

What is the best way to think "logically" when beginning programming, also, what are some great outside resources to learn programming on your own.

  Create a class called invoice that a hardware store

(Invoice Class) Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store.

  What transaction isolation level will you use

Suppose that you are writing a stored procedure to record a customer's purchase. Assume that the customer's data are new. How will you declare the boundaries of the transaction? What isolation level will you use?

  Update columns orderplaced subtotal shipping tax and totel

After a shopper completes an order, a procedure is called to update the following columns in the Basket table: orderplaced, subtotal, shipping, tax and total.

  Designing an efficient algorithm

What are the factors to be considered while designing an efficient algorithm?

  Create a five-vertex adjacency matrix and insert 0s and 1s

Now, without using the View button, create the corresponding directed graph using the GraphD workshop applet. When you're done, push the View button to see if the graph corresponds to your adjacency matrix.

  Report based on heuristic evaluation

Evaluate one of the websites listed below and create a report based on heuristic evaluation, consistency, and cognitive walkthrough.

  Characterize the difference in running times

Which gives the better performance, binary search on a sorted list, or sequential search on a list ordered by frequency where the frequence conforms to a Zipf distribution? Characterize the difference in running times.

  Application of artificial intelligence what are application

what are application of artificial intelligence in different fields and also explain it? ltbrgtwhat are application of

  Names and numbers of london-based suppliers

Give the relational algebra expression for the following English queries. 1. Get the supplier# who supply all the blue parts

  Design and implement a set of useful helper functions

Design and implement a set of useful helper functions for the Date class with functions such as next_workday() (assume that any day that is not a Saturday or a Sunday is a workday) and week_of_year() (assume that week 1 is the week with January 1 ..

  Write client and server programs that implement framework

The server needs some way of knowing which two sockets belong to the same client. One way to do this is to have the client first create a listening socket using an ephemeral port (i.e., binding to port 0).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd