SlideShare a Scribd company logo
1 of 6
Program Specifications in c++
Develop an inventory management system for an electronics store. The inventory system should
have the following functionalities:
BuildInventory: read a text file containing electronics products information and dynamically
store them in an array of pointers.
ShowInventory: display all inventory items.
UpdateInventory: ask for item id and quantity. If found display cost and update Product object
info (reduce Product's quantity and potentially update restocking flag).
Terminate: save current inventory to a text file.
This programming assignment illustrates the following concepts:
Text file reading and writing.
Arrays of pointers and dynamic memory allocations with new and delete.
Inheritance.
C++ type casting: static_cast.
NOTE: This assignment is not about polymorphism or dynamic_cast! Your program should not
contain any virtual function and/or use of dynamic_cast mechanism or point deductions will
apply. You will have opportunity to use polymorphism in the next assignment.
Class Design
You need at least three classes.
class InventoryItem (minimum implementation specified below) - This is the base class.
Protected member data: item id (integer) and restocking (bool).
Public static data:
const integer (item id): initialize to 9999.
const bool (restocking): initialize to false.
Constructors
Default constructor: initialize item id and restocking using the default static data with member
initializer syntax.
Non-default constructor: take 2 parameters.
Destructor: output "InventoryItem <item id> with <true/false> restocking destroyed ..."
Public member functions:
mutator/accessor for restocking, item id.
Display : to show InventoryItem item id and restocking (true/false). item id must be displayed as
a 4-digit integer with leading 0s if < 1000.
class Product : derived from InventoryItem class (minimum implementation specified below).
Private member data: name (string), quantity (integer) and price (double).
Public static data:
const string (name): "No Product".
const int (quantity): 0
const double (price): 0.99
Constructors (use member initializer syntax)
Default constructor: set member data to static data's default values above. Must explicitly invoke
the base class' default constructor.
Non-default constructor: take five parameters (id, restocking, name, quantity and price). Must
explicitly invoke the base class' non-default constructor.
Destructor: output "Product: <item id>, Name<name>, quantity<quantity>, price <price>,
restocking<true/false> destroyed ...".
Public member functions:
accessors/mutators for name, quantity, price.
Display: invoke Display from base class, then display its own data. NOTE: If the product
restocking is true somehow indicate it using "special effects" such as ***** or whatever effect
you'd like.
Cost : take an integer as its only parameter representing the quantity (how many product to be
sold) and return the total cost (price * quantity parameter).
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 display 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 and display a message asking for restocking).
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 and product count.
Implementation Requirements
Must use static_cast to downcast the InventoryItem base pointers to Product derived pointers in
order to access Product objects' functions as needed. Without the casting you only have Item *
pointer which can only access Item's member functions, not Product's member functions even
though the Item * pointers do point to Product objects.
If you are accessing member data in member functions do not use getters or accessors. The
member functions should have direct access to member data (even if they're declared as private)
and base class' protected member data.
Your text file must contain at least 8 products (you may come up with your own product data).
Here is how your main program should be implemented:
Declare a pointer to InventorySystem object and properly initialize it to nullptr (last time that I
will remind you about initializing variables at declarations in C++)
Dynamically allocate an InventorySystem object using the non-default constructor (making up
the data as needed).
Invoke BuildInventory
Invoke ShowInventory
Invoke UpdateInventory
Invoke Terminate
De-allocate InventorySystem object
In this assignment you're allowed to use array notation syntax such as product_list [ i ] as this is a
pointer to an InventoryItem object (InventoryItem *). If you wish (my preference) you may try to
use double pointer syntax InventoryItem ** to iterate through the array and de-reference it to get
a pointer to the Product object. Try to get your program crash and scream or curse :-) That's the
best way to learn C++ pointers.
Starting with this assignment you're on your way to implement non-trivial programs. One
suggestion is to divide the implementation into several phases:
Phase 1: implement the classes, one class at a time with an empty main function. Sometimes it's
a good idea to just implement one member function and go to phase 2 to verify it. Then come
back here to implement the next member function. For example you should implement
BuildInventory ( ) function first (as it reads a text file). In the function try to output the first,
middle and last elements in the array and check it against your text file. That will help to tell if
you've loaded the text file correctly into the array of pointers. I can help you with some code
here:
<must do static_cast here which I won't show the code> product_list [ 0 ]->Display ( ); // first
element
<must do static_cast here which I won't show the code> product_list [ 3 ]->Display ( ); //
middle element
<must do static_cast here which I won't show the code> product_list [ 7 ]->Display ( ); // last
element assuming your text file has only 8 products
if ( product_list [ 8 ] == nullptr ) {
cout << "Yes my array only loads that much data! Hooray!" << endl;
}
If your program crashes due to one of those statements I love it! You know how to get help I
assume.
Phase 2: test your implemented classes by trying to create/instantiate the objects from the classes
in phase 1 in the main function and see if you can use the accessor, mutator and member
functions correctly. You may want to add cout output statements to those functions to verify the
results as needed. Remove the output statements after you feel your classes are robust.
Comeback to phase 1 as needed.
Phase 3: start implementing what the program is trying to solve using objects.
Phase 4: testing your program thoroughly.
Text file format
One Product per line. Each Product data is separated by semi-colon ;
id1;Name1;Quantity1;Price1
id2;Name2;Quantity2;Price2
id3;Name3;Quantity3;Price3
For example:
901;Panasonic DVD Player;45;128.99
36789;iPhone Battery;120;35.99
784;Sony Camcoder;125;395.99
1231;Samsung TV;0;298.99
7734;Apple iPhone 8;1200;599.98
Note: you can figure out the restocking value (true of false) based on quantity value in the text
file.

More Related Content

Similar to Program Specifications in c++ Develop an inventory management system f.docx

Qtp 92 Tutorial769
Qtp 92 Tutorial769Qtp 92 Tutorial769
Qtp 92 Tutorial769subhasis100
 
Qtp 92 Tutorial Anil
Qtp 92 Tutorial AnilQtp 92 Tutorial Anil
Qtp 92 Tutorial Anilguest3373d3
 
Qtp 9.2 Tutorial
Qtp 9.2 TutorialQtp 9.2 Tutorial
Qtp 9.2 Tutorialguest37ae7f
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfoliomwillmer
 
1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docxhoney690131
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfeyebolloptics
 
Begin with the InventoryItem class and InventoryDemo fronte.pdf
Begin with the InventoryItem class and InventoryDemo fronte.pdfBegin with the InventoryItem class and InventoryDemo fronte.pdf
Begin with the InventoryItem class and InventoryDemo fronte.pdfaartienterprises2014
 
I really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdfI really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdfpasqualealvarez467
 
Assignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docxAssignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docxssuser562afc1
 
all i need is these two filesCreate VectorContainer.hppCreat.docx
all i need is these two filesCreate VectorContainer.hppCreat.docxall i need is these two filesCreate VectorContainer.hppCreat.docx
all i need is these two filesCreate VectorContainer.hppCreat.docxjack60216
 
ObjectivesUse inheritance to create base and child classes.docx
ObjectivesUse inheritance to create base and child classes.docxObjectivesUse inheritance to create base and child classes.docx
ObjectivesUse inheritance to create base and child classes.docxmccormicknadine86
 
I have the first program completed (not how request, but it works) a.pdf
I have the first program completed (not how request, but it works) a.pdfI have the first program completed (not how request, but it works) a.pdf
I have the first program completed (not how request, but it works) a.pdffootworld1
 
PT1420 File Access and Visual Basic .docx
PT1420 File Access and Visual Basic                      .docxPT1420 File Access and Visual Basic                      .docx
PT1420 File Access and Visual Basic .docxamrit47
 
Assignment6~$signment6.docxAssignment6Assignment6.docxAs.docx
Assignment6~$signment6.docxAssignment6Assignment6.docxAs.docxAssignment6~$signment6.docxAssignment6Assignment6.docxAs.docx
Assignment6~$signment6.docxAssignment6Assignment6.docxAs.docxssuser562afc1
 
Diving into VS 2015 Day5
Diving into VS 2015 Day5Diving into VS 2015 Day5
Diving into VS 2015 Day5Akhil Mittal
 

Similar to Program Specifications in c++ Develop an inventory management system f.docx (19)

Ppt Qtp
Ppt QtpPpt Qtp
Ppt Qtp
 
Qtp 92 Tutorial769
Qtp 92 Tutorial769Qtp 92 Tutorial769
Qtp 92 Tutorial769
 
Qtp 92 Tutorial Anil
Qtp 92 Tutorial AnilQtp 92 Tutorial Anil
Qtp 92 Tutorial Anil
 
Qtp 9.2 Tutorial
Qtp 9.2 TutorialQtp 9.2 Tutorial
Qtp 9.2 Tutorial
 
Qtp 92 Tutorial769
Qtp 92 Tutorial769Qtp 92 Tutorial769
Qtp 92 Tutorial769
 
E-Bazaar
E-BazaarE-Bazaar
E-Bazaar
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
 
1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdf
 
Begin with the InventoryItem class and InventoryDemo fronte.pdf
Begin with the InventoryItem class and InventoryDemo fronte.pdfBegin with the InventoryItem class and InventoryDemo fronte.pdf
Begin with the InventoryItem class and InventoryDemo fronte.pdf
 
I really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdfI really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdf
 
Assignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docxAssignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docx
 
all i need is these two filesCreate VectorContainer.hppCreat.docx
all i need is these two filesCreate VectorContainer.hppCreat.docxall i need is these two filesCreate VectorContainer.hppCreat.docx
all i need is these two filesCreate VectorContainer.hppCreat.docx
 
Constructor,destructors cpp
Constructor,destructors cppConstructor,destructors cpp
Constructor,destructors cpp
 
ObjectivesUse inheritance to create base and child classes.docx
ObjectivesUse inheritance to create base and child classes.docxObjectivesUse inheritance to create base and child classes.docx
ObjectivesUse inheritance to create base and child classes.docx
 
I have the first program completed (not how request, but it works) a.pdf
I have the first program completed (not how request, but it works) a.pdfI have the first program completed (not how request, but it works) a.pdf
I have the first program completed (not how request, but it works) a.pdf
 
PT1420 File Access and Visual Basic .docx
PT1420 File Access and Visual Basic                      .docxPT1420 File Access and Visual Basic                      .docx
PT1420 File Access and Visual Basic .docx
 
Assignment6~$signment6.docxAssignment6Assignment6.docxAs.docx
Assignment6~$signment6.docxAssignment6Assignment6.docxAs.docxAssignment6~$signment6.docxAssignment6Assignment6.docxAs.docx
Assignment6~$signment6.docxAssignment6Assignment6.docxAs.docx
 
Diving into VS 2015 Day5
Diving into VS 2015 Day5Diving into VS 2015 Day5
Diving into VS 2015 Day5
 

More from sharold2

Q4- If the mean is larger than the median- the distribution is said to.docx
Q4- If the mean is larger than the median- the distribution is said to.docxQ4- If the mean is larger than the median- the distribution is said to.docx
Q4- If the mean is larger than the median- the distribution is said to.docxsharold2
 
Q4- If the mean is larger than the median- the distribution is said to (1).docx
Q4- If the mean is larger than the median- the distribution is said to (1).docxQ4- If the mean is larger than the median- the distribution is said to (1).docx
Q4- If the mean is larger than the median- the distribution is said to (1).docxsharold2
 
Q32) The formation of new synapses is called- a)Synaptogenesis b)Fusi.docx
Q32)  The formation of new synapses is called- a)Synaptogenesis b)Fusi.docxQ32)  The formation of new synapses is called- a)Synaptogenesis b)Fusi.docx
Q32) The formation of new synapses is called- a)Synaptogenesis b)Fusi.docxsharold2
 
Q3-19- Think about what the terms density-dependent and densityindepen.docx
Q3-19- Think about what the terms density-dependent and densityindepen.docxQ3-19- Think about what the terms density-dependent and densityindepen.docx
Q3-19- Think about what the terms density-dependent and densityindepen.docxsharold2
 
Q3- Organizations need change because A) The future is unpredictable B.docx
Q3- Organizations need change because A) The future is unpredictable B.docxQ3- Organizations need change because A) The future is unpredictable B.docx
Q3- Organizations need change because A) The future is unpredictable B.docxsharold2
 
Q3- A Smurf attack is a type of distributed denial of service (DDoS) a.docx
Q3- A Smurf attack is a type of distributed denial of service (DDoS) a.docxQ3- A Smurf attack is a type of distributed denial of service (DDoS) a.docx
Q3- A Smurf attack is a type of distributed denial of service (DDoS) a.docxsharold2
 
Q3) -2 points- Using the DGIM method- show step by step how the bits a.docx
Q3) -2 points- Using the DGIM method- show step by step how the bits a.docxQ3) -2 points- Using the DGIM method- show step by step how the bits a.docx
Q3) -2 points- Using the DGIM method- show step by step how the bits a.docxsharold2
 
Q2 Generalize- 1 Point What is 3(p1)(q1)+1(modpq) - Q3 Cryptography- 1.docx
Q2 Generalize- 1 Point What is 3(p1)(q1)+1(modpq) - Q3 Cryptography- 1.docxQ2 Generalize- 1 Point What is 3(p1)(q1)+1(modpq) - Q3 Cryptography- 1.docx
Q2 Generalize- 1 Point What is 3(p1)(q1)+1(modpq) - Q3 Cryptography- 1.docxsharold2
 
Q1b- 12 Points The configuration shown below consists of identical com.docx
Q1b- 12 Points The configuration shown below consists of identical com.docxQ1b- 12 Points The configuration shown below consists of identical com.docx
Q1b- 12 Points The configuration shown below consists of identical com.docxsharold2
 
Q12- -15 points- Pfizer has identified 15 R-&D projects that will tie.docx
Q12- -15 points- Pfizer has identified 15 R-&D projects that will tie.docxQ12- -15 points- Pfizer has identified 15 R-&D projects that will tie.docx
Q12- -15 points- Pfizer has identified 15 R-&D projects that will tie.docxsharold2
 
Q1- Write about Jodie Foster's role as a nurse in the movie -Hotel Art.docx
Q1- Write about Jodie Foster's role as a nurse in the movie -Hotel Art.docxQ1- Write about Jodie Foster's role as a nurse in the movie -Hotel Art.docx
Q1- Write about Jodie Foster's role as a nurse in the movie -Hotel Art.docxsharold2
 
Q1- Since you cannot inventory services- matching supply and demand fo.docx
Q1- Since you cannot inventory services- matching supply and demand fo.docxQ1- Since you cannot inventory services- matching supply and demand fo.docx
Q1- Since you cannot inventory services- matching supply and demand fo.docxsharold2
 
Q1- Descriptors of a distribution are said to be reliable when data se.docx
Q1- Descriptors of a distribution are said to be reliable when data se.docxQ1- Descriptors of a distribution are said to be reliable when data se.docx
Q1- Descriptors of a distribution are said to be reliable when data se.docxsharold2
 
Q1) Why do managers organize their teams in terms of business processe.docx
Q1) Why do managers organize their teams in terms of business processe.docxQ1) Why do managers organize their teams in terms of business processe.docx
Q1) Why do managers organize their teams in terms of business processe.docxsharold2
 
Q1) Why has the hosts method for managing DNS largely been abandoned-.docx
Q1) Why has the hosts method for managing DNS largely been abandoned-.docxQ1) Why has the hosts method for managing DNS largely been abandoned-.docx
Q1) Why has the hosts method for managing DNS largely been abandoned-.docxsharold2
 
Q1) Suppose that the government deficit (D) is 20 - interest on the go.docx
Q1) Suppose that the government deficit (D) is 20 - interest on the go.docxQ1) Suppose that the government deficit (D) is 20 - interest on the go.docx
Q1) Suppose that the government deficit (D) is 20 - interest on the go.docxsharold2
 
Q1) List some of the issues that made us worry about the rising rate o.docx
Q1) List some of the issues that made us worry about the rising rate o.docxQ1) List some of the issues that made us worry about the rising rate o.docx
Q1) List some of the issues that made us worry about the rising rate o.docxsharold2
 
Q1 Mops (Type an integer or a decimal- Do not round).docx
Q1 Mops (Type an integer or a decimal- Do not round).docxQ1 Mops (Type an integer or a decimal- Do not round).docx
Q1 Mops (Type an integer or a decimal- Do not round).docxsharold2
 
Q- Explain how FRAs are like swaps and how they are different-.docx
Q- Explain how FRAs are like swaps and how they are different-.docxQ- Explain how FRAs are like swaps and how they are different-.docx
Q- Explain how FRAs are like swaps and how they are different-.docxsharold2
 

More from sharold2 (20)

Q4- If the mean is larger than the median- the distribution is said to.docx
Q4- If the mean is larger than the median- the distribution is said to.docxQ4- If the mean is larger than the median- the distribution is said to.docx
Q4- If the mean is larger than the median- the distribution is said to.docx
 
Q4- If the mean is larger than the median- the distribution is said to (1).docx
Q4- If the mean is larger than the median- the distribution is said to (1).docxQ4- If the mean is larger than the median- the distribution is said to (1).docx
Q4- If the mean is larger than the median- the distribution is said to (1).docx
 
Q32) The formation of new synapses is called- a)Synaptogenesis b)Fusi.docx
Q32)  The formation of new synapses is called- a)Synaptogenesis b)Fusi.docxQ32)  The formation of new synapses is called- a)Synaptogenesis b)Fusi.docx
Q32) The formation of new synapses is called- a)Synaptogenesis b)Fusi.docx
 
Q3-19- Think about what the terms density-dependent and densityindepen.docx
Q3-19- Think about what the terms density-dependent and densityindepen.docxQ3-19- Think about what the terms density-dependent and densityindepen.docx
Q3-19- Think about what the terms density-dependent and densityindepen.docx
 
Q3- Organizations need change because A) The future is unpredictable B.docx
Q3- Organizations need change because A) The future is unpredictable B.docxQ3- Organizations need change because A) The future is unpredictable B.docx
Q3- Organizations need change because A) The future is unpredictable B.docx
 
Q3- A Smurf attack is a type of distributed denial of service (DDoS) a.docx
Q3- A Smurf attack is a type of distributed denial of service (DDoS) a.docxQ3- A Smurf attack is a type of distributed denial of service (DDoS) a.docx
Q3- A Smurf attack is a type of distributed denial of service (DDoS) a.docx
 
Q3) -2 points- Using the DGIM method- show step by step how the bits a.docx
Q3) -2 points- Using the DGIM method- show step by step how the bits a.docxQ3) -2 points- Using the DGIM method- show step by step how the bits a.docx
Q3) -2 points- Using the DGIM method- show step by step how the bits a.docx
 
Q2 Generalize- 1 Point What is 3(p1)(q1)+1(modpq) - Q3 Cryptography- 1.docx
Q2 Generalize- 1 Point What is 3(p1)(q1)+1(modpq) - Q3 Cryptography- 1.docxQ2 Generalize- 1 Point What is 3(p1)(q1)+1(modpq) - Q3 Cryptography- 1.docx
Q2 Generalize- 1 Point What is 3(p1)(q1)+1(modpq) - Q3 Cryptography- 1.docx
 
Q1b- 12 Points The configuration shown below consists of identical com.docx
Q1b- 12 Points The configuration shown below consists of identical com.docxQ1b- 12 Points The configuration shown below consists of identical com.docx
Q1b- 12 Points The configuration shown below consists of identical com.docx
 
Q12- -15 points- Pfizer has identified 15 R-&D projects that will tie.docx
Q12- -15 points- Pfizer has identified 15 R-&D projects that will tie.docxQ12- -15 points- Pfizer has identified 15 R-&D projects that will tie.docx
Q12- -15 points- Pfizer has identified 15 R-&D projects that will tie.docx
 
Q1-.docx
Q1-.docxQ1-.docx
Q1-.docx
 
Q1- Write about Jodie Foster's role as a nurse in the movie -Hotel Art.docx
Q1- Write about Jodie Foster's role as a nurse in the movie -Hotel Art.docxQ1- Write about Jodie Foster's role as a nurse in the movie -Hotel Art.docx
Q1- Write about Jodie Foster's role as a nurse in the movie -Hotel Art.docx
 
Q1- Since you cannot inventory services- matching supply and demand fo.docx
Q1- Since you cannot inventory services- matching supply and demand fo.docxQ1- Since you cannot inventory services- matching supply and demand fo.docx
Q1- Since you cannot inventory services- matching supply and demand fo.docx
 
Q1- Descriptors of a distribution are said to be reliable when data se.docx
Q1- Descriptors of a distribution are said to be reliable when data se.docxQ1- Descriptors of a distribution are said to be reliable when data se.docx
Q1- Descriptors of a distribution are said to be reliable when data se.docx
 
Q1) Why do managers organize their teams in terms of business processe.docx
Q1) Why do managers organize their teams in terms of business processe.docxQ1) Why do managers organize their teams in terms of business processe.docx
Q1) Why do managers organize their teams in terms of business processe.docx
 
Q1) Why has the hosts method for managing DNS largely been abandoned-.docx
Q1) Why has the hosts method for managing DNS largely been abandoned-.docxQ1) Why has the hosts method for managing DNS largely been abandoned-.docx
Q1) Why has the hosts method for managing DNS largely been abandoned-.docx
 
Q1) Suppose that the government deficit (D) is 20 - interest on the go.docx
Q1) Suppose that the government deficit (D) is 20 - interest on the go.docxQ1) Suppose that the government deficit (D) is 20 - interest on the go.docx
Q1) Suppose that the government deficit (D) is 20 - interest on the go.docx
 
Q1) List some of the issues that made us worry about the rising rate o.docx
Q1) List some of the issues that made us worry about the rising rate o.docxQ1) List some of the issues that made us worry about the rising rate o.docx
Q1) List some of the issues that made us worry about the rising rate o.docx
 
Q1 Mops (Type an integer or a decimal- Do not round).docx
Q1 Mops (Type an integer or a decimal- Do not round).docxQ1 Mops (Type an integer or a decimal- Do not round).docx
Q1 Mops (Type an integer or a decimal- Do not round).docx
 
Q- Explain how FRAs are like swaps and how they are different-.docx
Q- Explain how FRAs are like swaps and how they are different-.docxQ- Explain how FRAs are like swaps and how they are different-.docx
Q- Explain how FRAs are like swaps and how they are different-.docx
 

Recently uploaded

Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 

Recently uploaded (20)

Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 

Program Specifications in c++ Develop an inventory management system f.docx

  • 1. Program Specifications in c++ Develop an inventory management system for an electronics store. The inventory system should have the following functionalities: BuildInventory: read a text file containing electronics products information and dynamically store them in an array of pointers. ShowInventory: display all inventory items. UpdateInventory: ask for item id and quantity. If found display cost and update Product object info (reduce Product's quantity and potentially update restocking flag). Terminate: save current inventory to a text file. This programming assignment illustrates the following concepts: Text file reading and writing. Arrays of pointers and dynamic memory allocations with new and delete. Inheritance. C++ type casting: static_cast. NOTE: This assignment is not about polymorphism or dynamic_cast! Your program should not contain any virtual function and/or use of dynamic_cast mechanism or point deductions will apply. You will have opportunity to use polymorphism in the next assignment. Class Design You need at least three classes. class InventoryItem (minimum implementation specified below) - This is the base class. Protected member data: item id (integer) and restocking (bool). Public static data: const integer (item id): initialize to 9999. const bool (restocking): initialize to false. Constructors
  • 2. Default constructor: initialize item id and restocking using the default static data with member initializer syntax. Non-default constructor: take 2 parameters. Destructor: output "InventoryItem <item id> with <true/false> restocking destroyed ..." Public member functions: mutator/accessor for restocking, item id. Display : to show InventoryItem item id and restocking (true/false). item id must be displayed as a 4-digit integer with leading 0s if < 1000. class Product : derived from InventoryItem class (minimum implementation specified below). Private member data: name (string), quantity (integer) and price (double). Public static data: const string (name): "No Product". const int (quantity): 0 const double (price): 0.99 Constructors (use member initializer syntax) Default constructor: set member data to static data's default values above. Must explicitly invoke the base class' default constructor. Non-default constructor: take five parameters (id, restocking, name, quantity and price). Must explicitly invoke the base class' non-default constructor. Destructor: output "Product: <item id>, Name<name>, quantity<quantity>, price <price>, restocking<true/false> destroyed ...". Public member functions: accessors/mutators for name, quantity, price. Display: invoke Display from base class, then display its own data. NOTE: If the product restocking is true somehow indicate it using "special effects" such as ***** or whatever effect you'd like.
  • 3. Cost : take an integer as its only parameter representing the quantity (how many product to be sold) and return the total cost (price * quantity parameter). 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:
  • 4. 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 display 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 and display a message asking for restocking). 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 and product count. Implementation Requirements Must use static_cast to downcast the InventoryItem base pointers to Product derived pointers in order to access Product objects' functions as needed. Without the casting you only have Item * pointer which can only access Item's member functions, not Product's member functions even though the Item * pointers do point to Product objects. If you are accessing member data in member functions do not use getters or accessors. The member functions should have direct access to member data (even if they're declared as private) and base class' protected member data. Your text file must contain at least 8 products (you may come up with your own product data). Here is how your main program should be implemented: Declare a pointer to InventorySystem object and properly initialize it to nullptr (last time that I will remind you about initializing variables at declarations in C++) Dynamically allocate an InventorySystem object using the non-default constructor (making up the data as needed). Invoke BuildInventory Invoke ShowInventory Invoke UpdateInventory
  • 5. Invoke Terminate De-allocate InventorySystem object In this assignment you're allowed to use array notation syntax such as product_list [ i ] as this is a pointer to an InventoryItem object (InventoryItem *). If you wish (my preference) you may try to use double pointer syntax InventoryItem ** to iterate through the array and de-reference it to get a pointer to the Product object. Try to get your program crash and scream or curse :-) That's the best way to learn C++ pointers. Starting with this assignment you're on your way to implement non-trivial programs. One suggestion is to divide the implementation into several phases: Phase 1: implement the classes, one class at a time with an empty main function. Sometimes it's a good idea to just implement one member function and go to phase 2 to verify it. Then come back here to implement the next member function. For example you should implement BuildInventory ( ) function first (as it reads a text file). In the function try to output the first, middle and last elements in the array and check it against your text file. That will help to tell if you've loaded the text file correctly into the array of pointers. I can help you with some code here: <must do static_cast here which I won't show the code> product_list [ 0 ]->Display ( ); // first element <must do static_cast here which I won't show the code> product_list [ 3 ]->Display ( ); // middle element <must do static_cast here which I won't show the code> product_list [ 7 ]->Display ( ); // last element assuming your text file has only 8 products if ( product_list [ 8 ] == nullptr ) { cout << "Yes my array only loads that much data! Hooray!" << endl; } If your program crashes due to one of those statements I love it! You know how to get help I assume. Phase 2: test your implemented classes by trying to create/instantiate the objects from the classes in phase 1 in the main function and see if you can use the accessor, mutator and member functions correctly. You may want to add cout output statements to those functions to verify the results as needed. Remove the output statements after you feel your classes are robust. Comeback to phase 1 as needed. Phase 3: start implementing what the program is trying to solve using objects.
  • 6. Phase 4: testing your program thoroughly. Text file format One Product per line. Each Product data is separated by semi-colon ; id1;Name1;Quantity1;Price1 id2;Name2;Quantity2;Price2 id3;Name3;Quantity3;Price3 For example: 901;Panasonic DVD Player;45;128.99 36789;iPhone Battery;120;35.99 784;Sony Camcoder;125;395.99 1231;Samsung TV;0;298.99 7734;Apple iPhone 8;1200;599.98 Note: you can figure out the restocking value (true of false) based on quantity value in the text file.