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++ MPL
Additional Engineering Textbook Solutions
Modern Database Management (12th Edition)
Computer Science: An Overview (12th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Database Concepts (8th Edition)
Software Engineering (10th Edition)
Starting Out With Visual Basic (7th Edition)
- T/F A method defined in a class can access the class' instance data without needing to pass them as parameters or declare them as local variables.arrow_forwardC++arrow_forwardTrue/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_forward
- Employee 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_forwardThe class implementation: The Account class) Design a class named Account that contains: A private int data field named id for the account (default 0). A private double data field named balance for the account (default 0). A private double data field named annuallnterestRate that stores the urrent interest rate (default 0). Assume all accounts have the same interestarrow_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