Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions

Question

Find limx f(x) if, for all x > 1, 10e 21

Answered: 1 week ago

Question

How would you describe your typical day at work?

Answered: 1 week ago