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.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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

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.

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

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

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

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education