Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is an Incomplete C ++ problem, so please JUST give me some hints and examples, thank you. I found some similar questions online, but
This is an Incomplete C ++ problem, so please JUST give me some hints and examples, thank you.
I found some similar questions online, but they are different from this.
class InventorySystem: (minimum implementation specified below). This class maintains an Inventory which is an array of pointers to InventoryItem which "point" to Product objects (Product class is derived from the base class InventoryItem) as shown below:
- Public static data
- constant integer denoting array size (initialized to 512).
- constant string as default value for store name ("My Store").
- constant int as default value for product count ( 0 ).
- constant string for Input file name.
- constant string for Output file name.
- Private member data
- Store name
- Product list (array of pointers to InventoryItem object whose size is the static data of value 512).
- Product count (tracking how many items are currently stored in the array (or the inventory). This information should be used to control the loop whenever the Product list array is processed.
- Constructors
- Default constructor: set member data to the static default values as appropriate (must use member initializer syntax). Use a loop to explicitly initialize all pointers in the array to nullptr.
- Non-default constructor: taking a string for store name. Do similar initialization as specified in default constructor.
- Destructor: Finally our destructor has something to work for: de-allocate dynamic memory for individual Product objects in the array of pointers (up to product count elements).
- Private member function:
- FindInventoryItem: take an integer as item id and search through the array of pointers for a match. If found return the InventoryItem pointer (InventoryItem * is the return type of the function) to the found Product. Otherwise return nullptr.
- Public member functions:
- BuildInventory: read a text file (its name is the static data) containing Product records (one Product per line), dynamically allocate Product objects (by using Product's non-default constructor) and store the objects in the array product_list (the array of InventoryItem pointers). It should update product count member data accordingly to keep track of the number of inventory items in the system.
- ShowInventory: display all Products in the inventory. Output must be properly formatted and aligned (using field width and floating data with 2 digits after decimal point). Hint: A loop to go thru the array of product list may dispolay only InventoryItem information. Extra work is needed to properly display both InventoryItem (base) and Products (derived objects) information.
- UpdateInventory: ask for item id and quantity. Invoke the FindInventoryItem function. If such a Product is found display total cost and update Product object (reduce Product's quantity. If quantity becomes 0 update restocking to true).
- Terminate: iterate through the array of pointers to write Product objects information to a text file (its name is the static data) in the same format as the input file's.
- mutators/accessors for store name, store id and item count.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started