SlideShare a Scribd company logo
according to the given UML class diagram, you’re required to design the following classes:
Package
TwoDayPackage
OvernightPackage
You are also required to write a driver’s program (name it as Assignment7.cpp) to create several
objects from above classes and do the relevant computation on them.
Section 3: Program description
3.1 Introduction
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
TwoDayPackage and OvernightPackage 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 above data members.
Package should provide a public member function calculateCost() that returns a double value
indicting the cost associated with shipping the package.
Package’s calculateCost() function should determine the cost by multiplying the weight by the
cost per ounce.
Below please find the UML diagram for Package class.
1
Package
#senderName: string #senderAddress: string #senderCity: string #senderState: string #senderZip:
int
#recipientName: string #recipientAddress: string #recipientCity: string #recipientState: string
#recipientZip: int
#weight: double #costPerOunce: double
+Package(string &sName, string &sAddress, string &sCity, string &sState, int sZIP,
string &rName, string &rAddress, string &rCity, string &rState, int rZIP, double w, double cost)
+getSenderName(): string +getSenderAddress(): string +getSenderCity(): string
+getSenderState(): string +getSenderZIP(): int
+getRecipientName(): string +getRecipientAddress(): string +getRecipientCity(): string
+getRecipientState(): string +getRecipientZIP(): int
+getWeight(): double +setWeight(double ):void +getCostPerOunce(): double
+setCostPerOunce(double ): void
+toString(): string
+calculateCost(): double
Package class
It is a base class, which will be used to derive the following two sub classes later on:
TwoDayPackage
OvernightPackage
Function calculateCost() will need to be override later.
Function toString() will print the package’s info. in the following format.
 Sender’s Name:ttJohn Smith
 Sender’s Address:ttNo.1 Main St, Phoenix, AZ, 85004
  Recipient’s Name:ttMary Johnson
2
 Recipient’s Address:tt124th St, Boston, MA, 55555   Weight:tt8.50 lb
 Cost:tt$0.65 per ounce
4) For Package class’s constructor, we provided the local variables’ name to make the
initialization clear.
TwoDayPackage class
It is a sub-class of Package class, i.e. it inherits from class Package
It 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.
TwoDayPackage’s constructor should also receive a value to initialize data member flatFee.
During initialization procedure, make sure call Package’s constructor first.
TwoDayPackage should redefine member function 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() function.
Besides the information printed in the toString() function of Package class, the toString()
function in TwoDayPackage class will also need to print the following information on screen:
 Flat Fee:tt$8.50
Below please find the UML diagram for TwoDayPackage class
TwoDayPackage
-flatFee : double
+TwoDayPackage(string &sName, string &sAddress, string &sCity, string &sState, int sZIP,
string &rName, string &rAddress, string &rCity, string &rState, int rZIP, double w, double cost,
double flatFee)
+getFlatFee(): double +setFlatFee( double ): void +toString(): string
OvernightPackage class
It is a sub-class of Package class, i.e. it inherits from class Package
It should inherit the functionality of base class Package, but also include a data member that
represents an additional fee per ounce charges to the standard cost for overnight-delivery service.
OvernightPackage’s constructor should receive a value to initialize data member
overnightFeePerOunce. Make sure call Package’s constructor first.
OvernightPackage should redefine member function calculateCost() so that it computes the
shipping cost by adding the overnight fee per ounce to the standard cost per ounce.
3
5) Besides the information printed in the toString() function of Package class, the toString()
function in OvernightPackage class will also need to print the following information on screen:
 Overnight Fee:tt$0.25 per ounce
Below please find the UML diagram for OvernightPackage class
OvernightPackage
-overnightFeePerOunce : double
+OvernightPackage(string &sName, string &sAddress, string &sCity, string &sState, int sZIP,
string &rName, string &rAddress, string &rCity, string &rState, int rZIP, double w, double cost,
double overnightFee)
+getOvernightFeePerOunce(): double +setOvernightFeePerOunce(double ): void +toString():
string
3.2 Programming Instructions
First, you will need to create the following files to represent these classes:
Package.h : this is the header file which declares the Package class
Package.cpp : this is the class implementation file for Package class
TwoDayPackage.h: this is the header file which declares the TwoDayPackage class
TwoDayPackage.cpp: this is the class implementation file for TwoDayPackage class
OvernightPackage.h: this is the header file which declares the OvernightPackage class
OvernightPackage.cpp: this is the class implementation file for OvernightPackage class
Second, you also need to create a driver program Assignment7.cpp that contains a main function.
Your main program will do the following:
1) Create an array which contains 3 packages.
Package #1 is a general package which contains the following information inside:
Sender: Lou Brown
Address: 1 Main St, Boston, MA 11111
Recipient: Mary Smith
Address: 7 Elm St, New York, NY 22222
Package weight: 8.5 ounces
Cost per ounce: $3.50
Package #2 is a two day package which contains the following information inside:
Sender: Lisa Klein
Address: 5 Broadway, Somerville, AZ 33333
Recipient: Bob George
Address: 21 Pine Rd, Scottsdale, AZ 44444
Package weight: 10.5 ounces
Cost per ounce: $0.65
Flat Fee: $3.00
4
Package #3 is an overnight package which contains the following information inside:
Sender: Ed Lewis
Address: 2 Oak St, Chandler, AZ 55555
Recipient: Don Kelly
Address: 9 Main St, Denver, CO 66666
Package weight: 12.25 ounces
Cost per ounce: $7.65
Overnight Fee: $0.25 per ounce
Use a for loop to traverse the array, for each package, invoke the get functions to obtain the
address information of the sender and the recipient, then print the two addresses as they would
appear on mailing labels.
Also, call each Package’s calculateCost() member function and print the result as follows:
Package 1
Sender:
Lou Brown
1 Main St
Boston, MA 11111
Recipient:
Mary Smith
7 Elm St
New York, NY 22222
Cost: $29.75
4) Keep track of the total shipping cost for all 3 Packages in the array and display the total cost
as follows when the loop terminates.
Total shipping cost: $???.??
Check and Run Your Program by Using Provided Output Test Case
Compare your program’s output with our solution output, namely soluOutput.txt, make sure they
are same.
Next save your program’s output as output1.txt, since you will need to submit the two files.
Section 4: Grading Rubric
Student correctly designed the Package.h file [3 pts]
Student correctly implement the Package.cpp file [5 pts]
Student correctly inherits & design the TwoDayPackage.h file [1 pts]
Student correctly implement the TwoDayPackage.cpp file, especially the constructor and
correctly override the calculateCost() and toString( )function [2 pts]
5
Student correctly inherits & design the OvernightPackage.h file [1 pt]
Student correctly implement the OvernightPackage.cpp file, especially the constructor and
correctly override the calculateCost() and toString( )function [2 pts]
In main(), students correctly created the 3 package objects [1 pt]
The program student submitted compiles, runs, and produces the correct output which matches
the test cases [5 pts]
Solution
PROGRAM CODE:
Package.h
/*
* Package.h
*
* Created on: 17-Nov-2016
* Author: kasturi
*/
#ifndef PACKAGE_H_
#define PACKAGE_H_
#include
using namespace std;
class Package
{
public:
string senderName;
string senderAddress;
string senderCity;
string senderState;
int senderZip;
string recipientName, recipientAddress, recipientCity, recipientState;
int recipientZip;
double weight;
double costPerOunce;
Package();
Package(string sName, string sAddress, string sCity, string sState, int sZIP,string rName,
string rAddress, string rCity, string rState, int rZIP, double w, double cost);
double calculateCost();
string getSenderName();
string getSenderAddress();
string getSenderCity();
string getSenderState();
int getSenderZIP();
string getRecipientName();
string getRecipientAddress();
string getRecipientCity();
string getRecipientState();
int getRecipientZIP();
double getWeight();
double getCostPerOunce();
void setWeight(double w);
void setCostPerOunce(double cost);
string toString();
};
#endif /* PACKAGE_H_ */
Package.cpp
/*
* Package.cpp
*
* Created on: 16-Nov-2016
* Author: kasturi
*/
#include "Package.h"
using namespace std;
Package::Package(string sName, string sAddress, string sCity, string sState, int sZIP,string
rName, string rAddress, string rCity, string rState, int rZIP, double w, double cost)
{
senderName = sName;
senderAddress = sAddress;
senderCity = sCity;
senderState = sState;
senderZip = sZIP;
recipientName = rName;
recipientAddress = rAddress;
recipientCity = rCity;
recipientState = rState;
recipientZip = rZIP;
weight = w;
costPerOunce = cost;
}
double Package:: calculateCost()
{
return costPerOunce*weight;
}
string Package::getSenderName()
{
return senderName;
}
string Package::getSenderAddress()
{
return senderAddress;
}
string Package::getSenderCity()
{
return senderCity;
}
string Package::getSenderState()
{
return senderState;
}
int Package::getSenderZIP()
{
return senderZip;
}
string Package::getRecipientName()
{
return recipientName;
}
string Package::getRecipientAddress()
{
return recipientAddress;
}
string Package::getRecipientCity()
{
return recipientCity;
}
string Package::getRecipientState()
{
return recipientState;
}
int Package::getRecipientZIP()
{
return recipientZip;
}
double Package::getWeight()
{
return weight;
}
double Package::getCostPerOunce()
{
return costPerOunce;
}
void Package::setWeight(double w)
{
weight = w;
}
void Package::setCostPerOunce(double cost)
{
costPerOunce = cost;
}
string Package::toString()
{
return " Sender's Name:tt" + senderName +
" Sender's Address:tt" + senderAddress + ", " + senderCity + ", " + senderState + ", " +
to_string(senderZip) +
"  Recipient's Name:tt" + recipientName +
" Recipient's Address:tt" + recipientAddress + ", " + recipientCity + ", " + recipientState
+ ", " + to_string(recipientZip) +
"  Weight:tt" + to_string(weight) +
" Cost:tt$" + to_string(costPerOunce) + "per ounce";
}
OvernightPackage.h
/*
* OvernightPackage.h
*
* Created on: 17-Nov-2016
* Author: kasturi
*/
#ifndef OVERNIGHTPACKAGE_H_
#define OVERNIGHTPACKAGE_H_
#include "Package.h"
#include
using namespace std;
class OvernightPackage : public Package
{
private:
double overnightFeePerOunce;
public:
OvernightPackage(string sName, string sAddress, string sCity, string sState, int sZIP, string
rName, string rAddress, string rCity, string rState, int rZIP, double w, double cost, double
overnightFee);
string getOvernightFeePerOunce();
void etOvernightFeePerOunce(double fee);
string toString();
double calculateCost();
};
#endif /* OVERNIGHTPACKAGE_H_ */
OvernightPackage.cpp
/*
* OvernightPackage.cpp
*
* Created on: 17-Nov-2016
* Author: kasturi
*/
#include "OvernightPackage.h"
#include "Package.h"
#include
using namespace std;
OvernightPackage::OvernightPackage(string sName, string sAddress, string sCity, string
sState, int sZIP, string rName, string rAddress, string rCity, string rState, int rZIP, double w,
double cost, double overnightFee)
:Package(sName, sAddress, sCity, sState, sZIP, rName, rAddress, rCity, rState,rZIP, w, cost )
{
overnightFeePerOunce = overnightFee;
}
string OvernightPackage::toString()
{
string value = Package::toString() + " Overnight Fee:tt$" +
to_string(overnightFeePerOunce) + " per ounce";
return value;
}
double OvernightPackage::calculateCost()
{
return (overnightFeePerOunce + costPerOunce) * weight;
}
TwoDayPackage.h
/*
* TwoDayPackage.h
*
* Created on: 17-Nov-2016
* Author: kasturi
*/
#ifndef TWODAYPACKAGE_H_
#define TWODAYPACKAGE_H_
#include
#include "Package.h"
using namespace std;
class TwoDayPackage : public Package
{
private:
double flatFee;
public:
TwoDayPackage(string sName, string sAddress, string sCity, string sState, int sZIP, string
rName, string rAddress, string rCity, string rState, int rZIP, double w, double cost, double fee);
double getFlatFee();
void setFlatFee( double fee);
string toString();
double calculateCost();
};
#endif /* TWODAYPACKAGE_H_ */
TwoDayPackage.cpp
/*
* TwoDayPackage.cpp
*
* Created on: 16-Nov-2016
* Author: kasturi
*/
#include "TwoDayPackage.h"
#include "Package.h"
using namespace std;
TwoDayPackage::TwoDayPackage(string sName, string sAddress, string sCity, string sState, int
sZIP, string rName, string rAddress, string rCity, string rState, int rZIP, double w, double cost,
double fee)
:Package(sName, sAddress, sCity, sState, sZIP, rName, rAddress, rCity, rState,rZIP, w, cost )
{
flatFee = fee;
}
double TwoDayPackage::getFlatFee()
{
return flatFee;
}
void TwoDayPackage::setFlatFee( double fee)
{
flatFee = fee;
}
string TwoDayPackage::toString()
{
string value = Package::toString() + " Flat Fee:tt$" + to_string(flatFee);
return value;
}
double TwoDayPackage::calculateCost()
{
return Package::calculateCost() + flatFee;
}
Assignment7.cpp
/*
* Assignment7.cpp
*
* Created on: 17-Nov-2016
* Author: kasturi
*/
#include "Package.h"
#include "OvernightPackage.h"
#include "TwoDayPackage.h"
#include
#include
using namespace std;
int main()
{
double totalCost = 0.00;
Package **packages = new Package*[3];
packages[0] = new Package("Lou Brown", "1 Main St", "Boston", "MA", 11111, "Mary
Smith", "7 Elm St", "New York", "NY", 22222, 8.5, 3.50);
packages[1] = new TwoDayPackage("Lisa Klein", "5 Broadway", "Somerville", "AZ",
33333, "Bob George", "21 Pine Rd", "Scottsdale", "AZ", 44444, 10.5, 0.65, 3.00);
packages[2] = new OvernightPackage("EdLewis", "2 Oak St" ,"Chandler", "AZ", 55555,
"Don Kelly", "9 Main St", "Denver", "CO", 66666, 12.25, 7.65, 0.25);
//printing the address information for each sender and recipient
for(int i=0; i<3; i++)
{
cout<<"Package "<getSenderName()<getSenderAddress()<getSenderCity()<<",
"<getSenderState()<<"
"<getSenderZIP()<getRecipientName()<getRecipientAddress()<getRecipientCity()<<",
"<getRecipientState()<<" "<getRecipientZIP()<calculateCost()<calculateCost();
}
cout<<"Total shipping cost: $"<

More Related Content

Similar to according to the given UML class diagram, you’re required to design .pdf

c#(loops,arrays)
c#(loops,arrays)c#(loops,arrays)
c#(loops,arrays)sdrhr
 
EN3085 Assessed Coursework 1 1. Create a class Complex .docx
EN3085 Assessed Coursework 1  1. Create a class Complex .docxEN3085 Assessed Coursework 1  1. Create a class Complex .docx
EN3085 Assessed Coursework 1 1. Create a class Complex .docxgidmanmary
 
Automate the boring stuff with python
Automate the boring stuff with pythonAutomate the boring stuff with python
Automate the boring stuff with pythonDEEPAKSINGHBIST1
 
I have the first program completed (not how request, but it works) a.pdf
I have the first program completed (not how request, but it works) a.pdfI have the first program completed (not how request, but it works) a.pdf
I have the first program completed (not how request, but it works) a.pdffootworld1
 
Name _______________________________ Class time __________.docx
Name _______________________________    Class time __________.docxName _______________________________    Class time __________.docx
Name _______________________________ Class time __________.docxrosemarybdodson23141
 
CSCI2312 – Object Oriented Programming Section 003 Homewo
CSCI2312 – Object Oriented Programming  Section 003 HomewoCSCI2312 – Object Oriented Programming  Section 003 Homewo
CSCI2312 – Object Oriented Programming Section 003 Homewosimisterchristen
 
Sp 1418794917
Sp 1418794917Sp 1418794917
Sp 1418794917lakshmi r
 
The second programming assignment (HW4) is designed to help you ga.docx
The second programming assignment (HW4) is designed to help you ga.docxThe second programming assignment (HW4) is designed to help you ga.docx
The second programming assignment (HW4) is designed to help you ga.docxoreo10
 
Section1 compound data class
Section1 compound data classSection1 compound data class
Section1 compound data classDương Tùng
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfeyebolloptics
 
Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06Barry DeCicco
 
Using c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdfUsing c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdffashiongallery1
 
Go Programming by Example_ Nho Vĩnh Share.pdf
Go Programming by Example_ Nho Vĩnh Share.pdfGo Programming by Example_ Nho Vĩnh Share.pdf
Go Programming by Example_ Nho Vĩnh Share.pdfNho Vĩnh
 
Cis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablesCis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablescis247
 

Similar to according to the given UML class diagram, you’re required to design .pdf (20)

c#(loops,arrays)
c#(loops,arrays)c#(loops,arrays)
c#(loops,arrays)
 
EN3085 Assessed Coursework 1 1. Create a class Complex .docx
EN3085 Assessed Coursework 1  1. Create a class Complex .docxEN3085 Assessed Coursework 1  1. Create a class Complex .docx
EN3085 Assessed Coursework 1 1. Create a class Complex .docx
 
Extending ns
Extending nsExtending ns
Extending ns
 
Devtools cheatsheet
Devtools cheatsheetDevtools cheatsheet
Devtools cheatsheet
 
Devtools cheatsheet
Devtools cheatsheetDevtools cheatsheet
Devtools cheatsheet
 
Automate the boring stuff with python
Automate the boring stuff with pythonAutomate the boring stuff with python
Automate the boring stuff with python
 
I have the first program completed (not how request, but it works) a.pdf
I have the first program completed (not how request, but it works) a.pdfI have the first program completed (not how request, but it works) a.pdf
I have the first program completed (not how request, but it works) a.pdf
 
Name _______________________________ Class time __________.docx
Name _______________________________    Class time __________.docxName _______________________________    Class time __________.docx
Name _______________________________ Class time __________.docx
 
CSCI2312 – Object Oriented Programming Section 003 Homewo
CSCI2312 – Object Oriented Programming  Section 003 HomewoCSCI2312 – Object Oriented Programming  Section 003 Homewo
CSCI2312 – Object Oriented Programming Section 003 Homewo
 
Unit4_2.pdf
Unit4_2.pdfUnit4_2.pdf
Unit4_2.pdf
 
CS3391 -OOP -UNIT – II NOTES FINAL.pdf
CS3391 -OOP -UNIT – II  NOTES FINAL.pdfCS3391 -OOP -UNIT – II  NOTES FINAL.pdf
CS3391 -OOP -UNIT – II NOTES FINAL.pdf
 
Sp 1418794917
Sp 1418794917Sp 1418794917
Sp 1418794917
 
The second programming assignment (HW4) is designed to help you ga.docx
The second programming assignment (HW4) is designed to help you ga.docxThe second programming assignment (HW4) is designed to help you ga.docx
The second programming assignment (HW4) is designed to help you ga.docx
 
Section1 compound data class
Section1 compound data classSection1 compound data class
Section1 compound data class
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdf
 
Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06
 
Class and object
Class and objectClass and object
Class and object
 
Using c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdfUsing c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdf
 
Go Programming by Example_ Nho Vĩnh Share.pdf
Go Programming by Example_ Nho Vĩnh Share.pdfGo Programming by Example_ Nho Vĩnh Share.pdf
Go Programming by Example_ Nho Vĩnh Share.pdf
 
Cis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablesCis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variables
 

More from arpitcomputronics

Neutrons cant be detected by the same detectors as alphas, betas, and.pdf
Neutrons cant be detected by the same detectors as alphas, betas, and.pdfNeutrons cant be detected by the same detectors as alphas, betas, and.pdf
Neutrons cant be detected by the same detectors as alphas, betas, and.pdfarpitcomputronics
 
List each hypothesis that is being tested in a twofactor ANOVA.S.pdf
List each hypothesis that is being tested in a twofactor ANOVA.S.pdfList each hypothesis that is being tested in a twofactor ANOVA.S.pdf
List each hypothesis that is being tested in a twofactor ANOVA.S.pdfarpitcomputronics
 
Marla begins walking at 3 mih toward the library.Her friend meets h.pdf
Marla begins walking at 3 mih toward the library.Her friend meets h.pdfMarla begins walking at 3 mih toward the library.Her friend meets h.pdf
Marla begins walking at 3 mih toward the library.Her friend meets h.pdfarpitcomputronics
 
Mrs. S confides in you that she is terrified of her husband. She rep.pdf
Mrs. S confides in you that she is terrified of her husband. She rep.pdfMrs. S confides in you that she is terrified of her husband. She rep.pdf
Mrs. S confides in you that she is terrified of her husband. She rep.pdfarpitcomputronics
 
In September of 2008, the FDIC paid JP Morgan Chase to purchase all .pdf
In September of 2008, the FDIC paid JP Morgan Chase to purchase all .pdfIn September of 2008, the FDIC paid JP Morgan Chase to purchase all .pdf
In September of 2008, the FDIC paid JP Morgan Chase to purchase all .pdfarpitcomputronics
 
In cocker spaniels, black coat color (B) is dominant over red (b), an.pdf
In cocker spaniels, black coat color (B) is dominant over red (b), an.pdfIn cocker spaniels, black coat color (B) is dominant over red (b), an.pdf
In cocker spaniels, black coat color (B) is dominant over red (b), an.pdfarpitcomputronics
 
In most healthy people, toxoplasmosis is an inapparent or mild dise.pdf
In most healthy people, toxoplasmosis is an inapparent or mild dise.pdfIn most healthy people, toxoplasmosis is an inapparent or mild dise.pdf
In most healthy people, toxoplasmosis is an inapparent or mild dise.pdfarpitcomputronics
 
I only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdfI only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdfarpitcomputronics
 
Identify and briefly describe a diffusion network that you have expe.pdf
Identify and briefly describe a diffusion network that you have expe.pdfIdentify and briefly describe a diffusion network that you have expe.pdf
Identify and briefly describe a diffusion network that you have expe.pdfarpitcomputronics
 
how do the masses of the earth, oceans, atmosphere, and biosphere co.pdf
how do the masses of the earth, oceans, atmosphere, and biosphere co.pdfhow do the masses of the earth, oceans, atmosphere, and biosphere co.pdf
how do the masses of the earth, oceans, atmosphere, and biosphere co.pdfarpitcomputronics
 
If the mechanism of DNA replication (semi-conservative, conservative.pdf
If the mechanism of DNA replication (semi-conservative, conservative.pdfIf the mechanism of DNA replication (semi-conservative, conservative.pdf
If the mechanism of DNA replication (semi-conservative, conservative.pdfarpitcomputronics
 
EYCONNEC Cell Structures the arrangement of phospholipids in the plas.pdf
EYCONNEC Cell Structures the arrangement of phospholipids in the plas.pdfEYCONNEC Cell Structures the arrangement of phospholipids in the plas.pdf
EYCONNEC Cell Structures the arrangement of phospholipids in the plas.pdfarpitcomputronics
 
For the balance sheet, please categorize the following as short-term.pdf
For the balance sheet, please categorize the following as short-term.pdfFor the balance sheet, please categorize the following as short-term.pdf
For the balance sheet, please categorize the following as short-term.pdfarpitcomputronics
 
During World War II, the Manhattan Project developed the first nuclea.pdf
During World War II, the Manhattan Project developed the first nuclea.pdfDuring World War II, the Manhattan Project developed the first nuclea.pdf
During World War II, the Manhattan Project developed the first nuclea.pdfarpitcomputronics
 
Deoxy sugars are modified sugars where one or more OH groups are remo.pdf
Deoxy sugars are modified sugars where one or more OH groups are remo.pdfDeoxy sugars are modified sugars where one or more OH groups are remo.pdf
Deoxy sugars are modified sugars where one or more OH groups are remo.pdfarpitcomputronics
 
Determine truth value of the statement. Domain consists of all real .pdf
Determine truth value of the statement. Domain consists of all real .pdfDetermine truth value of the statement. Domain consists of all real .pdf
Determine truth value of the statement. Domain consists of all real .pdfarpitcomputronics
 
Describe the niches of at least 3 species of wildlife that might be .pdf
Describe the niches of at least 3 species of wildlife that might be .pdfDescribe the niches of at least 3 species of wildlife that might be .pdf
Describe the niches of at least 3 species of wildlife that might be .pdfarpitcomputronics
 
Define multicollinearity in the following termsa. In which type o.pdf
Define multicollinearity in the following termsa. In which type o.pdfDefine multicollinearity in the following termsa. In which type o.pdf
Define multicollinearity in the following termsa. In which type o.pdfarpitcomputronics
 
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdf
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdfConvert the for loop Into MIPS Instructions. Use the sit instruction .pdf
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdfarpitcomputronics
 
Clarify how cells and molecules are linked to tissuesSolutionA.pdf
Clarify how cells and molecules are linked to tissuesSolutionA.pdfClarify how cells and molecules are linked to tissuesSolutionA.pdf
Clarify how cells and molecules are linked to tissuesSolutionA.pdfarpitcomputronics
 

More from arpitcomputronics (20)

Neutrons cant be detected by the same detectors as alphas, betas, and.pdf
Neutrons cant be detected by the same detectors as alphas, betas, and.pdfNeutrons cant be detected by the same detectors as alphas, betas, and.pdf
Neutrons cant be detected by the same detectors as alphas, betas, and.pdf
 
List each hypothesis that is being tested in a twofactor ANOVA.S.pdf
List each hypothesis that is being tested in a twofactor ANOVA.S.pdfList each hypothesis that is being tested in a twofactor ANOVA.S.pdf
List each hypothesis that is being tested in a twofactor ANOVA.S.pdf
 
Marla begins walking at 3 mih toward the library.Her friend meets h.pdf
Marla begins walking at 3 mih toward the library.Her friend meets h.pdfMarla begins walking at 3 mih toward the library.Her friend meets h.pdf
Marla begins walking at 3 mih toward the library.Her friend meets h.pdf
 
Mrs. S confides in you that she is terrified of her husband. She rep.pdf
Mrs. S confides in you that she is terrified of her husband. She rep.pdfMrs. S confides in you that she is terrified of her husband. She rep.pdf
Mrs. S confides in you that she is terrified of her husband. She rep.pdf
 
In September of 2008, the FDIC paid JP Morgan Chase to purchase all .pdf
In September of 2008, the FDIC paid JP Morgan Chase to purchase all .pdfIn September of 2008, the FDIC paid JP Morgan Chase to purchase all .pdf
In September of 2008, the FDIC paid JP Morgan Chase to purchase all .pdf
 
In cocker spaniels, black coat color (B) is dominant over red (b), an.pdf
In cocker spaniels, black coat color (B) is dominant over red (b), an.pdfIn cocker spaniels, black coat color (B) is dominant over red (b), an.pdf
In cocker spaniels, black coat color (B) is dominant over red (b), an.pdf
 
In most healthy people, toxoplasmosis is an inapparent or mild dise.pdf
In most healthy people, toxoplasmosis is an inapparent or mild dise.pdfIn most healthy people, toxoplasmosis is an inapparent or mild dise.pdf
In most healthy people, toxoplasmosis is an inapparent or mild dise.pdf
 
I only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdfI only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdf
 
Identify and briefly describe a diffusion network that you have expe.pdf
Identify and briefly describe a diffusion network that you have expe.pdfIdentify and briefly describe a diffusion network that you have expe.pdf
Identify and briefly describe a diffusion network that you have expe.pdf
 
how do the masses of the earth, oceans, atmosphere, and biosphere co.pdf
how do the masses of the earth, oceans, atmosphere, and biosphere co.pdfhow do the masses of the earth, oceans, atmosphere, and biosphere co.pdf
how do the masses of the earth, oceans, atmosphere, and biosphere co.pdf
 
If the mechanism of DNA replication (semi-conservative, conservative.pdf
If the mechanism of DNA replication (semi-conservative, conservative.pdfIf the mechanism of DNA replication (semi-conservative, conservative.pdf
If the mechanism of DNA replication (semi-conservative, conservative.pdf
 
EYCONNEC Cell Structures the arrangement of phospholipids in the plas.pdf
EYCONNEC Cell Structures the arrangement of phospholipids in the plas.pdfEYCONNEC Cell Structures the arrangement of phospholipids in the plas.pdf
EYCONNEC Cell Structures the arrangement of phospholipids in the plas.pdf
 
For the balance sheet, please categorize the following as short-term.pdf
For the balance sheet, please categorize the following as short-term.pdfFor the balance sheet, please categorize the following as short-term.pdf
For the balance sheet, please categorize the following as short-term.pdf
 
During World War II, the Manhattan Project developed the first nuclea.pdf
During World War II, the Manhattan Project developed the first nuclea.pdfDuring World War II, the Manhattan Project developed the first nuclea.pdf
During World War II, the Manhattan Project developed the first nuclea.pdf
 
Deoxy sugars are modified sugars where one or more OH groups are remo.pdf
Deoxy sugars are modified sugars where one or more OH groups are remo.pdfDeoxy sugars are modified sugars where one or more OH groups are remo.pdf
Deoxy sugars are modified sugars where one or more OH groups are remo.pdf
 
Determine truth value of the statement. Domain consists of all real .pdf
Determine truth value of the statement. Domain consists of all real .pdfDetermine truth value of the statement. Domain consists of all real .pdf
Determine truth value of the statement. Domain consists of all real .pdf
 
Describe the niches of at least 3 species of wildlife that might be .pdf
Describe the niches of at least 3 species of wildlife that might be .pdfDescribe the niches of at least 3 species of wildlife that might be .pdf
Describe the niches of at least 3 species of wildlife that might be .pdf
 
Define multicollinearity in the following termsa. In which type o.pdf
Define multicollinearity in the following termsa. In which type o.pdfDefine multicollinearity in the following termsa. In which type o.pdf
Define multicollinearity in the following termsa. In which type o.pdf
 
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdf
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdfConvert the for loop Into MIPS Instructions. Use the sit instruction .pdf
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdf
 
Clarify how cells and molecules are linked to tissuesSolutionA.pdf
Clarify how cells and molecules are linked to tissuesSolutionA.pdfClarify how cells and molecules are linked to tissuesSolutionA.pdf
Clarify how cells and molecules are linked to tissuesSolutionA.pdf
 

Recently uploaded

The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resourcesaileywriter
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptSourabh Kumar
 
Advances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfAdvances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfDr. M. Kumaresan Hort.
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resourcesdimpy50
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfTamralipta Mahavidyalaya
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxRaedMohamed3
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringDenish Jangid
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chipsGeoBlogs
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfYibeltalNibretu
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxakshayaramakrishnan21
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...Sayali Powar
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfQucHHunhnh
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsCol Mukteshwar Prasad
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfbu07226
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...Nguyen Thanh Tu Collection
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxssuserbdd3e8
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportAvinash Rai
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxJenilouCasareno
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfVivekanand Anglo Vedic Academy
 

Recently uploaded (20)

The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
Advances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfAdvances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdf
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 

according to the given UML class diagram, you’re required to design .pdf

  • 1. according to the given UML class diagram, you’re required to design the following classes: Package TwoDayPackage OvernightPackage You are also required to write a driver’s program (name it as Assignment7.cpp) to create several objects from above classes and do the relevant computation on them. Section 3: Program description 3.1 Introduction 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 TwoDayPackage and OvernightPackage 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 above data members. Package should provide a public member function calculateCost() that returns a double value indicting the cost associated with shipping the package. Package’s calculateCost() function should determine the cost by multiplying the weight by the cost per ounce. Below please find the UML diagram for Package class. 1 Package #senderName: string #senderAddress: string #senderCity: string #senderState: string #senderZip: int #recipientName: string #recipientAddress: string #recipientCity: string #recipientState: string #recipientZip: int #weight: double #costPerOunce: double +Package(string &sName, string &sAddress, string &sCity, string &sState, int sZIP, string &rName, string &rAddress, string &rCity, string &rState, int rZIP, double w, double cost) +getSenderName(): string +getSenderAddress(): string +getSenderCity(): string +getSenderState(): string +getSenderZIP(): int +getRecipientName(): string +getRecipientAddress(): string +getRecipientCity(): string +getRecipientState(): string +getRecipientZIP(): int
  • 2. +getWeight(): double +setWeight(double ):void +getCostPerOunce(): double +setCostPerOunce(double ): void +toString(): string +calculateCost(): double Package class It is a base class, which will be used to derive the following two sub classes later on: TwoDayPackage OvernightPackage Function calculateCost() will need to be override later. Function toString() will print the package’s info. in the following format. Sender’s Name:ttJohn Smith Sender’s Address:ttNo.1 Main St, Phoenix, AZ, 85004 Recipient’s Name:ttMary Johnson 2 Recipient’s Address:tt124th St, Boston, MA, 55555 Weight:tt8.50 lb Cost:tt$0.65 per ounce 4) For Package class’s constructor, we provided the local variables’ name to make the initialization clear. TwoDayPackage class It is a sub-class of Package class, i.e. it inherits from class Package It 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. TwoDayPackage’s constructor should also receive a value to initialize data member flatFee. During initialization procedure, make sure call Package’s constructor first. TwoDayPackage should redefine member function 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() function. Besides the information printed in the toString() function of Package class, the toString() function in TwoDayPackage class will also need to print the following information on screen: Flat Fee:tt$8.50 Below please find the UML diagram for TwoDayPackage class TwoDayPackage -flatFee : double +TwoDayPackage(string &sName, string &sAddress, string &sCity, string &sState, int sZIP, string &rName, string &rAddress, string &rCity, string &rState, int rZIP, double w, double cost, double flatFee)
  • 3. +getFlatFee(): double +setFlatFee( double ): void +toString(): string OvernightPackage class It is a sub-class of Package class, i.e. it inherits from class Package It should inherit the functionality of base class Package, but also include a data member that represents an additional fee per ounce charges to the standard cost for overnight-delivery service. OvernightPackage’s constructor should receive a value to initialize data member overnightFeePerOunce. Make sure call Package’s constructor first. OvernightPackage should redefine member function calculateCost() so that it computes the shipping cost by adding the overnight fee per ounce to the standard cost per ounce. 3 5) Besides the information printed in the toString() function of Package class, the toString() function in OvernightPackage class will also need to print the following information on screen: Overnight Fee:tt$0.25 per ounce Below please find the UML diagram for OvernightPackage class OvernightPackage -overnightFeePerOunce : double +OvernightPackage(string &sName, string &sAddress, string &sCity, string &sState, int sZIP, string &rName, string &rAddress, string &rCity, string &rState, int rZIP, double w, double cost, double overnightFee) +getOvernightFeePerOunce(): double +setOvernightFeePerOunce(double ): void +toString(): string 3.2 Programming Instructions First, you will need to create the following files to represent these classes: Package.h : this is the header file which declares the Package class Package.cpp : this is the class implementation file for Package class TwoDayPackage.h: this is the header file which declares the TwoDayPackage class TwoDayPackage.cpp: this is the class implementation file for TwoDayPackage class OvernightPackage.h: this is the header file which declares the OvernightPackage class OvernightPackage.cpp: this is the class implementation file for OvernightPackage class Second, you also need to create a driver program Assignment7.cpp that contains a main function. Your main program will do the following: 1) Create an array which contains 3 packages. Package #1 is a general package which contains the following information inside: Sender: Lou Brown Address: 1 Main St, Boston, MA 11111 Recipient: Mary Smith
  • 4. Address: 7 Elm St, New York, NY 22222 Package weight: 8.5 ounces Cost per ounce: $3.50 Package #2 is a two day package which contains the following information inside: Sender: Lisa Klein Address: 5 Broadway, Somerville, AZ 33333 Recipient: Bob George Address: 21 Pine Rd, Scottsdale, AZ 44444 Package weight: 10.5 ounces Cost per ounce: $0.65 Flat Fee: $3.00 4 Package #3 is an overnight package which contains the following information inside: Sender: Ed Lewis Address: 2 Oak St, Chandler, AZ 55555 Recipient: Don Kelly Address: 9 Main St, Denver, CO 66666 Package weight: 12.25 ounces Cost per ounce: $7.65 Overnight Fee: $0.25 per ounce Use a for loop to traverse the array, for each package, invoke the get functions to obtain the address information of the sender and the recipient, then print the two addresses as they would appear on mailing labels. Also, call each Package’s calculateCost() member function and print the result as follows: Package 1 Sender: Lou Brown 1 Main St Boston, MA 11111 Recipient: Mary Smith 7 Elm St New York, NY 22222 Cost: $29.75 4) Keep track of the total shipping cost for all 3 Packages in the array and display the total cost as follows when the loop terminates.
  • 5. Total shipping cost: $???.?? Check and Run Your Program by Using Provided Output Test Case Compare your program’s output with our solution output, namely soluOutput.txt, make sure they are same. Next save your program’s output as output1.txt, since you will need to submit the two files. Section 4: Grading Rubric Student correctly designed the Package.h file [3 pts] Student correctly implement the Package.cpp file [5 pts] Student correctly inherits & design the TwoDayPackage.h file [1 pts] Student correctly implement the TwoDayPackage.cpp file, especially the constructor and correctly override the calculateCost() and toString( )function [2 pts] 5 Student correctly inherits & design the OvernightPackage.h file [1 pt] Student correctly implement the OvernightPackage.cpp file, especially the constructor and correctly override the calculateCost() and toString( )function [2 pts] In main(), students correctly created the 3 package objects [1 pt] The program student submitted compiles, runs, and produces the correct output which matches the test cases [5 pts] Solution PROGRAM CODE: Package.h /* * Package.h * * Created on: 17-Nov-2016 * Author: kasturi */ #ifndef PACKAGE_H_ #define PACKAGE_H_ #include using namespace std; class Package { public:
  • 6. string senderName; string senderAddress; string senderCity; string senderState; int senderZip; string recipientName, recipientAddress, recipientCity, recipientState; int recipientZip; double weight; double costPerOunce; Package(); Package(string sName, string sAddress, string sCity, string sState, int sZIP,string rName, string rAddress, string rCity, string rState, int rZIP, double w, double cost); double calculateCost(); string getSenderName(); string getSenderAddress(); string getSenderCity(); string getSenderState(); int getSenderZIP(); string getRecipientName(); string getRecipientAddress(); string getRecipientCity(); string getRecipientState(); int getRecipientZIP(); double getWeight(); double getCostPerOunce(); void setWeight(double w); void setCostPerOunce(double cost); string toString(); }; #endif /* PACKAGE_H_ */ Package.cpp /* * Package.cpp * * Created on: 16-Nov-2016
  • 7. * Author: kasturi */ #include "Package.h" using namespace std; Package::Package(string sName, string sAddress, string sCity, string sState, int sZIP,string rName, string rAddress, string rCity, string rState, int rZIP, double w, double cost) { senderName = sName; senderAddress = sAddress; senderCity = sCity; senderState = sState; senderZip = sZIP; recipientName = rName; recipientAddress = rAddress; recipientCity = rCity; recipientState = rState; recipientZip = rZIP; weight = w; costPerOunce = cost; } double Package:: calculateCost() { return costPerOunce*weight; } string Package::getSenderName() { return senderName; } string Package::getSenderAddress() { return senderAddress; } string Package::getSenderCity() { return senderCity;
  • 8. } string Package::getSenderState() { return senderState; } int Package::getSenderZIP() { return senderZip; } string Package::getRecipientName() { return recipientName; } string Package::getRecipientAddress() { return recipientAddress; } string Package::getRecipientCity() { return recipientCity; } string Package::getRecipientState() { return recipientState; } int Package::getRecipientZIP() { return recipientZip; } double Package::getWeight() { return weight; } double Package::getCostPerOunce() { return costPerOunce;
  • 9. } void Package::setWeight(double w) { weight = w; } void Package::setCostPerOunce(double cost) { costPerOunce = cost; } string Package::toString() { return " Sender's Name:tt" + senderName + " Sender's Address:tt" + senderAddress + ", " + senderCity + ", " + senderState + ", " + to_string(senderZip) + " Recipient's Name:tt" + recipientName + " Recipient's Address:tt" + recipientAddress + ", " + recipientCity + ", " + recipientState + ", " + to_string(recipientZip) + " Weight:tt" + to_string(weight) + " Cost:tt$" + to_string(costPerOunce) + "per ounce"; } OvernightPackage.h /* * OvernightPackage.h * * Created on: 17-Nov-2016 * Author: kasturi */ #ifndef OVERNIGHTPACKAGE_H_ #define OVERNIGHTPACKAGE_H_ #include "Package.h" #include using namespace std; class OvernightPackage : public Package { private: double overnightFeePerOunce;
  • 10. public: OvernightPackage(string sName, string sAddress, string sCity, string sState, int sZIP, string rName, string rAddress, string rCity, string rState, int rZIP, double w, double cost, double overnightFee); string getOvernightFeePerOunce(); void etOvernightFeePerOunce(double fee); string toString(); double calculateCost(); }; #endif /* OVERNIGHTPACKAGE_H_ */ OvernightPackage.cpp /* * OvernightPackage.cpp * * Created on: 17-Nov-2016 * Author: kasturi */ #include "OvernightPackage.h" #include "Package.h" #include using namespace std; OvernightPackage::OvernightPackage(string sName, string sAddress, string sCity, string sState, int sZIP, string rName, string rAddress, string rCity, string rState, int rZIP, double w, double cost, double overnightFee) :Package(sName, sAddress, sCity, sState, sZIP, rName, rAddress, rCity, rState,rZIP, w, cost ) { overnightFeePerOunce = overnightFee; } string OvernightPackage::toString() { string value = Package::toString() + " Overnight Fee:tt$" + to_string(overnightFeePerOunce) + " per ounce"; return value; } double OvernightPackage::calculateCost()
  • 11. { return (overnightFeePerOunce + costPerOunce) * weight; } TwoDayPackage.h /* * TwoDayPackage.h * * Created on: 17-Nov-2016 * Author: kasturi */ #ifndef TWODAYPACKAGE_H_ #define TWODAYPACKAGE_H_ #include #include "Package.h" using namespace std; class TwoDayPackage : public Package { private: double flatFee; public: TwoDayPackage(string sName, string sAddress, string sCity, string sState, int sZIP, string rName, string rAddress, string rCity, string rState, int rZIP, double w, double cost, double fee); double getFlatFee(); void setFlatFee( double fee); string toString(); double calculateCost(); }; #endif /* TWODAYPACKAGE_H_ */ TwoDayPackage.cpp /* * TwoDayPackage.cpp * * Created on: 16-Nov-2016 * Author: kasturi */
  • 12. #include "TwoDayPackage.h" #include "Package.h" using namespace std; TwoDayPackage::TwoDayPackage(string sName, string sAddress, string sCity, string sState, int sZIP, string rName, string rAddress, string rCity, string rState, int rZIP, double w, double cost, double fee) :Package(sName, sAddress, sCity, sState, sZIP, rName, rAddress, rCity, rState,rZIP, w, cost ) { flatFee = fee; } double TwoDayPackage::getFlatFee() { return flatFee; } void TwoDayPackage::setFlatFee( double fee) { flatFee = fee; } string TwoDayPackage::toString() { string value = Package::toString() + " Flat Fee:tt$" + to_string(flatFee); return value; } double TwoDayPackage::calculateCost() { return Package::calculateCost() + flatFee; } Assignment7.cpp /* * Assignment7.cpp * * Created on: 17-Nov-2016 * Author: kasturi */ #include "Package.h"
  • 13. #include "OvernightPackage.h" #include "TwoDayPackage.h" #include #include using namespace std; int main() { double totalCost = 0.00; Package **packages = new Package*[3]; packages[0] = new Package("Lou Brown", "1 Main St", "Boston", "MA", 11111, "Mary Smith", "7 Elm St", "New York", "NY", 22222, 8.5, 3.50); packages[1] = new TwoDayPackage("Lisa Klein", "5 Broadway", "Somerville", "AZ", 33333, "Bob George", "21 Pine Rd", "Scottsdale", "AZ", 44444, 10.5, 0.65, 3.00); packages[2] = new OvernightPackage("EdLewis", "2 Oak St" ,"Chandler", "AZ", 55555, "Don Kelly", "9 Main St", "Denver", "CO", 66666, 12.25, 7.65, 0.25); //printing the address information for each sender and recipient for(int i=0; i<3; i++) { cout<<"Package "<getSenderName()<getSenderAddress()<getSenderCity()<<", "<getSenderState()<<" "<getSenderZIP()<getRecipientName()<getRecipientAddress()<getRecipientCity()<<", "<getRecipientState()<<" "<getRecipientZIP()<calculateCost()<calculateCost(); } cout<<"Total shipping cost: $"<