Question: Given main ( ) and Product.h , define the Product class ( in Product.cpp ) that will manage product inventory. Product class has four private

Given main() and Product.h, define the Product class (in Product.cpp) that will manage product inventory. Product class has four private data members: the product's name (string), a product code (string), the product's price (double), and the number count of product in inventory (int).
Implement the following Constructor and member functions listed in the Product.h file:
Product(string name, string code, double price, int count)- set the data members using the four parameters
void SetName(string name)- set the product name to parameter name
string GetName()- return the product name
void SetCode(string code)- set the product code (i.e. SKU234) to parameter code
string GetCode()- return the product code
void SetPrice(double p)- set the price to parameter p
double GetPrice()- return the price
void SetCount(int num)- set the number of items in inventory to parameter num
int GetCount()- return the count
void AddInventory(int amt)- increase inventory by parameter amt
void SellInventory(int amt)- decrease inventory by parameter amt
Output each floating-point value with two digits after the decimal point, which can be achieved by executing
cout << fixed << setprecision(2); once before all other cout statements.
Ex. If a new Product object "Apple" is created with code set to "SKU234", price set to 0.40, and the count set to 3, the output is:
Name: Apple Code: SKU234 Price: 0.40 Count: 3
Ex. If 10 apples are added to the Product object's inventory, but then 5 are sold, the output is:
Name: Apple Code: SKU234 Price: 0.40 Count: 8
Ex. If the Product "Golden Delicious" object's code is set to "SKU555", price is set to 0.55, and count is set to 4, the output is:
Name: Golden Delicious Code: SKU555 Price: 0.55 Count: 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!