Concept explainers
Inventory Class
Design an Inventory class that can hold information for an item in a retail store’s inventory. The class should have the following private member variables.
Variable Name | Description |
itemNumber | An int that holds the item’s number. |
quantity | An int that holds the quantity of the item on hand. |
cost | A double that holds the wholesale per-unit cost of the item |
The class should have the following public member functions.
Member Function | Description | |
default constructor | Sets all the member variables to 0. | |
constructor #2 | Accepts an item’s number, quantity, and cost as arguments. Calls other class functions to copy these values into the appropriate member variables. Then calls the setTotalCost function. | |
Member Function | Description | |
setItemNumber | Accepts an int argument and copies it into the itemNumber member variable. | |
setQuantity | Accepts an int argument and copies it into the quantity member variable. | |
setCost | Accepts a double argument and copies it into the cost member variable. | |
getItemNumber | Returns the value in itemNumber. | |
getQuantity | Returns the value in quantity. | |
getCost | Returns the value in cost. | |
gotTotalCost | Computes and returns the totalCost. |
Demonstrate the class by writing a simple
Trending nowThis is a popular solution!
Chapter 7 Solutions
Starting Out With C++: Early Objects (10th Edition)
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Problem Solving with C++ (10th Edition)
Degarmo's Materials And Processes In Manufacturing
Concepts Of Programming Languages
Starting Out with Python (4th Edition)
- protected class members are only accessible inside the class (true/false) it’s possible to set the value of a private member variable of a class (true/false) setter and getter functions should be private (true/false)arrow_forwardEvery class must have at least one them: Your answer: O Constructor O Destructor 口 Member function OSet function 口 Get function O Data memberarrow_forwardObject composition is useful for creating a(n) _____relationship between two classes.arrow_forward
- True/False: a member function in a class can access all of its class's member variables, but not if the variables are private. A) True B) Falsearrow_forwardEmployee and ProductionWorker ClassesCreate an Employee class that has properties for the following data:Employee nameEmployee numberNext, create a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have properties to hold the following data:Shift number (an integer, such as 1, 2, or 3)Hourly pay rateThe workday is divided into two shifts: day and night. The Shift property will hold an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2.Create an application that creates an object of the ProductionWorker class and lets the user enter data for each of the object’s properties. Retrieve the object’s properties and display their values. this.ReportViewer1.Employee(); cannot reference?arrow_forwardC++arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education