Create an instance of Inventory class, stockltem1 using the default constructor. Display the itemNumber, quantity, cost and totalCost of stockltem1 2. Create another instance of Inventory class, stockltem2 using the overloaded constructor, and passing the following for itemNumber, quantity and cost - 124, 12, 84.95. Display the associated data for stockltem2. 3. Use the setter functions (mutators) to change the stockltem2 to 243, 50, 9.50. 4. Check the input validation by setting the itemNumber, quantity and cost to -1 using the setter functions. Observe the output.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 3PE: Chapter 10 defined the class circleType to implement the basic properties of a circle. (Add the...
icon
Related questions
Question

This program needs to be done in C++ coding language

* 00
RR
3.
Class
Request edit ace
Design an inventory class (Inventory.h) that holds the information for an item in a retail store's
inventory. Implement the class based on the UML diagram shown below:
Inventory
private:
int itemNumber;
int quantity;
double cost;
I/An int that holds the item's number
I/An int that holds the quantity of the item on hand
IIA double that holds the wholesale per-unit cost of the
item
public:
Inventory()
Inventory(int, int, double); 1/Overloaded constructor.
//Default constructor. Sets all the member variables to 0.
I/Accepts an item's number, quantity, and cost as arguments.
void setltemNumber(int); /I/Accepts an int argument and copies it into the
itemNumber member variable.
void setQuantity(int); //Accepts an int argument and copies it into the quantity
member
void setCost(double); IIAccepts a double argument and copies it into the cost
member variable
int getltemNumber(); I/ Returns the value in itemNumber
int getQuantity(); //Returns the value in quantity
double getCost(); //Returns the value in cost
double getTotalCost(); //Computes and returns the total cost
bool validInt(int); I/This function returns true if its integer argument is valid (i.e.
non-negative), and returns false otherwise.
bool validFloat(double); //This function returns true if its floating-point
argument is valid (i.e. non-negative), and returns false otherwise.
Implement all the methods specified above to complete the Inventory class.
In the tester program, Inventory.cpp, include the following operations.
MacBook Pro
000
000
&
$
%
)
9
8.
Transcribed Image Text:* 00 RR 3. Class Request edit ace Design an inventory class (Inventory.h) that holds the information for an item in a retail store's inventory. Implement the class based on the UML diagram shown below: Inventory private: int itemNumber; int quantity; double cost; I/An int that holds the item's number I/An int that holds the quantity of the item on hand IIA double that holds the wholesale per-unit cost of the item public: Inventory() Inventory(int, int, double); 1/Overloaded constructor. //Default constructor. Sets all the member variables to 0. I/Accepts an item's number, quantity, and cost as arguments. void setltemNumber(int); /I/Accepts an int argument and copies it into the itemNumber member variable. void setQuantity(int); //Accepts an int argument and copies it into the quantity member void setCost(double); IIAccepts a double argument and copies it into the cost member variable int getltemNumber(); I/ Returns the value in itemNumber int getQuantity(); //Returns the value in quantity double getCost(); //Returns the value in cost double getTotalCost(); //Computes and returns the total cost bool validInt(int); I/This function returns true if its integer argument is valid (i.e. non-negative), and returns false otherwise. bool validFloat(double); //This function returns true if its floating-point argument is valid (i.e. non-negative), and returns false otherwise. Implement all the methods specified above to complete the Inventory class. In the tester program, Inventory.cpp, include the following operations. MacBook Pro 000 000 & $ % ) 9 8.
+||
M
* 00
B
TT
V>
Request edit access
Implement all the methods specified above to complete the Inventory class.
In the tester program, Inventory.cpp, include the following operations.
1. Create an instance of Inventory class, stockltem1 using the default constructor. Display
the itemNumber, quantity, cost and totalCost of stockltem1
2. Create another instance of Inventory class, stockltem2 using the overloaded
constructor, and passing the following for itemNumber, quantity and cost - 124, 12,
84.95. Display the associated data for stockltem2.
3. Use the setter functions (mutators) to change the stockltem2 to 243, 50, 9.50.
4. Check the input validation by setting the itemNumber, quantity and cost to -1 using the
setter functions. Observe the output.
Submit both Inventory.h and Inventory.cpp files. Include sample output for all test cases.
Sample Output
* RUN OUTPUT PRODUCED BY THIS TEST PROGRAM
Demonstrating the default constructor..
Item number: 0
Quantity : 0
: 0.00
Cost
Total Cost : 0.00
Demonstrating the overloaded constructor...
Item number: 124
MacBook Pro
000
000
23
2$
4.
R
Y
M
Transcribed Image Text:+|| M * 00 B TT V> Request edit access Implement all the methods specified above to complete the Inventory class. In the tester program, Inventory.cpp, include the following operations. 1. Create an instance of Inventory class, stockltem1 using the default constructor. Display the itemNumber, quantity, cost and totalCost of stockltem1 2. Create another instance of Inventory class, stockltem2 using the overloaded constructor, and passing the following for itemNumber, quantity and cost - 124, 12, 84.95. Display the associated data for stockltem2. 3. Use the setter functions (mutators) to change the stockltem2 to 243, 50, 9.50. 4. Check the input validation by setting the itemNumber, quantity and cost to -1 using the setter functions. Observe the output. Submit both Inventory.h and Inventory.cpp files. Include sample output for all test cases. Sample Output * RUN OUTPUT PRODUCED BY THIS TEST PROGRAM Demonstrating the default constructor.. Item number: 0 Quantity : 0 : 0.00 Cost Total Cost : 0.00 Demonstrating the overloaded constructor... Item number: 124 MacBook Pro 000 000 23 2$ 4. R Y M
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage