Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

help with C++ please: General requirements for classes: 1. Each class should be declared in a file named as and implemented in a file named

help with C++ please:

General requirements for classes:

1. Each class should be declared in a file named as and implemented in a file

named where ClassName is the name of the class. For example, a class

named UsedFurnitureItem should be declared in a file named UsedFurnitureItem.h and

implemented in a file named UsedFurnitureItem.cpp.

2. Each class should provide a getter/setter for each private member. Setters should reject

meaningless values such as negative age.

3. The class should provide a default constructor that initializes the private member variables

to a reasonable value.

UsedFurnitureItem:

1. Create a class named UsedFurnitureItem to represent a used furniture item that the store sells.

2. Private data members of a UsedFurnitureItem are:

a. age (double) // age in years

b. brandNewPrice (double) // the original price of the item when it was brand new

c. description (string) // a string description of the item

d. condition (char) // condition of the item could be A, B, or C.

e. size (double) // the size of the item in cubic inches.

f. weight (double) // the weight of the item in pounds.

3. Public member functions of a UsedFurnitureItem are (in addition to getters/setters and

constructors):

a. CalculateCurrentPrice(): Current price depends on age, brandNewPrice, and condition

of the used furniture Item. If the item is in A-condition, the current price will go down

by extra 10% of the brandNewPrice for each year of its age until 7 years (e.g., After

the first year, and item with a $100 brandNewPrice will cost $90, after 2 years, $ 80,

and so on). If the age is greater than 7 years, the price is fixed at 30% of the

brandNewPrice. The current price of B-condition items goes down by extra 15 % of

the brandNewPrice for each year until the 5th year. After that, the current price is fixed

at 20% of the brandNewPrice. Items with C-condition are priced at 10% of the

brandNewPrice regardless of age.

b. CalculateShippingCost(): Shipping cost of a UsedFurnitureItem depends on weight,

size, and distance. While weight and size are member variables, shipping distance is

provided as an argument to this function. Shipping rate is 1 cent per mile for items

that are smaller than 1000 cubic inches and smaller than 20 pounds. Items with larger

size or weight cost 2 cents per mile.

UsedComputer:

1. Create a class named UsedComputer to represent a used computer item that the store sells.

2. Private data members of a UsedComputer are:

a. age (double) // age in years

b. model (string) // a string description of the computer

c. brandNewPrice (double) // the original price of the computer when it was brand

new

d. condition: (char) // condition of the item could be A, B, or C.

3. Public member functions of a UsedComputer are (in addition to getters/setters and

constructors)

a. CalculateCurrentPrice(): current price is calculated the same way a

UsedFurnatureItem is calculated.

b. CalculateShippingCost(): shipping cost depends on distance which is provided as

an argument. The shipping rate is 1 cent per mile.

Test Program:

Develop a test program that will test all functionalities of these two classes. In particular, the test

program will create one UsedFurnitureItem and one UsedComputer. The test program will test each

setter and getter by calling the setter to set a value and then call the getter to print out the set value.

Furthermore, the test program will call and print the result of CalculateCurrentPrice() and

CalculateShippingCost(). For example, to test UsedFurnitureItem, an object should be created, the

setter for weight should be called with a negative value. Then the getter for weight should be called

and its result printed to verify that weight was not set to a wrong value. Another call of the weight

setter with a reasonable value should made, and the getter for weight should be called to verify

correct setting. Once all member variables are set, CalculateCurrentPrice() and

CalculateShippingCost() should be called, and their results should be printed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

7-16 Compare Web 2.0 and Web 3.0.

Answered: 1 week ago