Question
Lab #8 Program 3 Gift Box Class and Client Program (give you more practice) 15 pts Step 1: Design a GiftWrap class Design (using a
Lab #8 Program 3 Gift Box Class and Client Program (give you more practice) 15 pts
Step 1: Design a
GiftWrap
class
Design (using a UML) a
GiftWrap
class that a gift wrapping store could use to calculate the price of
wrapping rectangular gift boxes and generate invoices/receipts for their customers. The class will
allow a gift wrapping store to calculate the cost of wrapping various sized rectangular boxes. The class
will have member functions to calculate the price of the gift wrap box being wrapped, tax on the gift
wrap sold, and the total cost of the gift wrap both including and excluding tax.
The class should have the following member variables:
?
length
this variable holds the length of the box in inches
?
width
this variable holds the width of the box in inches
?
height
this variable holds the height of the box in inches
?
taxRate
this variable holds the sales tax rate for the company
?
pricePerInch
this variable holds the price per inch of the gift wrap
The class should have the following member functions:
?
Two Constructors:
o
One constructor should be a no argument (no arg) constructor. This constructor should set the
length, width and height
member variables to 1.0, the
pricePerInch
member variable to 0.036,
and the
taxRate
member variable to 0.08.
o
One constructor that accepts the following
two
values as arguments (so the constructor should
have two parameter variables) and assigns them to the appropriate member variables: the tax
rate and the price per inch. This constructor should set the
length, width and length
member
variables to 1.0.
?
Do not allow the
pricePerInch
member variable to be set to numbers less than zero.
Use reasonable default values. Its up to you to know how to design this based on class
lecture on object oriented programming.
?
Do not allow the
taxRate
member variable to be set to a number less than zero or
greater than one. Use reasonable default values. Its up to you to know how to design
this based on class lecture on object oriented programming.
?
Five Set Functions:
o
Design a set function for each member variable:
length, width, height, pricePerInch,
and
taxRate
.
?
Do not allow the
length, width, height
, and
pricePerInch
member variables to be
set to numbers less than zero. Its up to you to know how to design this based
on class lecture on object oriented programming.
?
Do not allow the
taxRate
member variable to be set to a number less than zero or
greater than one. Its up to you to know how to design this based on class
lecture on object oriented programming.
.
?
Five Get Functions:
o
Design get function for each member variable:
length, width, height, pricePerInch,
and
taxRate
o
Its up to you to know how to design these functions based on class lecture on object oriented
programming.
?
calcSubtotal
Member Function:
o
This member function should calculate the price of the gift wrap BEFORE tax. The price of the
gift wrap before tax is calculated as follows:
1. First calculate the surface area of the box.
o
Surface Area = (2 * length * width) + (2 * length * height) + (2 * width * height)
2. Next multiply the surface area of the box by the price per inch. This is the subtotal for the
gift wrap.
?
calcTax
Member Function:
o
This member function should calculate the tax on the gift. The tax is the subtotal * the tax rate.
Be efficient and use existing functions if you can.
?
calcTotal
Member Function:
o
This member function should calculate the overall total price of the gift wrap which is the
subtotal + the tax. Be efficient and use e
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started