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.
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...
Related questions
Concept explainers
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd8437880-ab18-4369-b54f-6699dbe54753%2F56497c80-90e5-4753-9b1f-5972659e3cc5%2Fw7gkets.jpeg&w=3840&q=75)
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd8437880-ab18-4369-b54f-6699dbe54753%2F56497c80-90e5-4753-9b1f-5972659e3cc5%2Fv3jtr86.jpeg&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 4 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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.Recommended textbooks for you
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage