SlideShare a Scribd company logo
1 of 7
Download to read offline
show code and all classes with full implementation for these Program Specifications.
Example products ( camcorder, dvd player, blueray player, tv, camera, xbox 360, ps4, Wii,
laptops, iphone, battery, smart phones, computer desktop, printer, usb, mouse)
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.
Testing
Run the program four times to verify:
The text file was loaded successfully to show the correct Inventory data.
UpdateInventory will occur on the first, the middle (in this case ask for the max quantity to make
restocking data to be updated to true), the last Product and non-existing product (each time your
program is run select the correct or invalid product id for this to happen). Verify total cost is
correct when applicable.
Verify if the output text file is correct (Inventory is updated properly or the same as the original
text file when entering invalid product id).
show code and all classes with full implementation for these Program S.pdf

More Related Content

Similar to show code and all classes with full implementation for these Program S.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.pdfaartienterprises2014
Β 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfoliomwillmer
Β 
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
Β 
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
Β 
Qtp 92 Tutorial769
Qtp 92 Tutorial769Qtp 92 Tutorial769
Qtp 92 Tutorial769subhasis100
Β 
qtp 9.2 features
qtp 9.2 featuresqtp 9.2 features
qtp 9.2 featureskrishna3032
Β 
Qtp 92 Tutorial
Qtp 92 TutorialQtp 92 Tutorial
Qtp 92 Tutorialsasidhar
Β 
Ppt Qtp
Ppt QtpPpt Qtp
Ppt Qtprosaleenm
Β 
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
Β 
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
Β 
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
Β 
CS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docx
CS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docxCS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docx
CS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docxmydrynan
Β 
Assignment6~$signment6.docxAssignment6Assignment6.docxAs.docx
Assignment6~$signment6.docxAssignment6Assignment6.docxAs.docxAssignment6~$signment6.docxAssignment6Assignment6.docxAs.docx
Assignment6~$signment6.docxAssignment6Assignment6.docxAs.docxssuser562afc1
Β 
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
Β 
Diving into VS 2015 Day5
Diving into VS 2015 Day5Diving into VS 2015 Day5
Diving into VS 2015 Day5Akhil Mittal
Β 

Similar to show code and all classes with full implementation for these Program S.pdf (19)

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
Β 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
Β 
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
Β 
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
Β 
Qtp 92 Tutorial769
Qtp 92 Tutorial769Qtp 92 Tutorial769
Qtp 92 Tutorial769
Β 
qtp 9.2 features
qtp 9.2 featuresqtp 9.2 features
qtp 9.2 features
Β 
Qtp 92 Tutorial
Qtp 92 TutorialQtp 92 Tutorial
Qtp 92 Tutorial
Β 
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
Β 
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
Β 
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
Β 
CS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docx
CS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docxCS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docx
CS 2336 PROJECT 3 – Linked Inventory Management Project Due 1104 b.docx
Β 
Assignment6~$signment6.docxAssignment6Assignment6.docxAs.docx
Assignment6~$signment6.docxAssignment6Assignment6.docxAs.docxAssignment6~$signment6.docxAssignment6Assignment6.docxAs.docx
Assignment6~$signment6.docxAssignment6Assignment6.docxAs.docx
Β 
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
Β 
Diving into VS 2015 Day5
Diving into VS 2015 Day5Diving into VS 2015 Day5
Diving into VS 2015 Day5
Β 
Les22
Les22Les22
Les22
Β 

More from AlanSmDDyerl

Steps to Complete for the Problem Set Step 1- SPSS spreadsheet Put the.pdf
Steps to Complete for the Problem Set Step 1- SPSS spreadsheet Put the.pdfSteps to Complete for the Problem Set Step 1- SPSS spreadsheet Put the.pdf
Steps to Complete for the Problem Set Step 1- SPSS spreadsheet Put the.pdfAlanSmDDyerl
Β 
STEP 7 Assess the effect of the environmental change on future generat.pdf
STEP 7 Assess the effect of the environmental change on future generat.pdfSTEP 7 Assess the effect of the environmental change on future generat.pdf
STEP 7 Assess the effect of the environmental change on future generat.pdfAlanSmDDyerl
Β 
Step 1- Keep it Simple To get things started- Wily Corp wants to strea.pdf
Step 1- Keep it Simple To get things started- Wily Corp wants to strea.pdfStep 1- Keep it Simple To get things started- Wily Corp wants to strea.pdf
Step 1- Keep it Simple To get things started- Wily Corp wants to strea.pdfAlanSmDDyerl
Β 
Starting at age 25 and continuing to age 65- Haley deposited $2000 eve.pdf
Starting at age 25 and continuing to age 65- Haley deposited $2000 eve.pdfStarting at age 25 and continuing to age 65- Haley deposited $2000 eve.pdf
Starting at age 25 and continuing to age 65- Haley deposited $2000 eve.pdfAlanSmDDyerl
Β 
Starting on the day Anika was born- her mother has invested $40 at the.pdf
Starting on the day Anika was born- her mother has invested $40 at the.pdfStarting on the day Anika was born- her mother has invested $40 at the.pdf
Starting on the day Anika was born- her mother has invested $40 at the.pdfAlanSmDDyerl
Β 
Staining a specimen for microscopy is helpful because Select one or m.pdf
Staining a specimen for  microscopy is helpful because Select one or m.pdfStaining a specimen for  microscopy is helpful because Select one or m.pdf
Staining a specimen for microscopy is helpful because Select one or m.pdfAlanSmDDyerl
Β 
ssume that you have been assigned the 132-45-0-0-16 network block- Ide.pdf
ssume that you have been assigned the 132-45-0-0-16 network block- Ide.pdfssume that you have been assigned the 132-45-0-0-16 network block- Ide.pdf
ssume that you have been assigned the 132-45-0-0-16 network block- Ide.pdfAlanSmDDyerl
Β 
spreadsheet question Philbin Financial Group titus Fund ilimmary Desin.pdf
spreadsheet question Philbin Financial Group titus Fund ilimmary Desin.pdfspreadsheet question Philbin Financial Group titus Fund ilimmary Desin.pdf
spreadsheet question Philbin Financial Group titus Fund ilimmary Desin.pdfAlanSmDDyerl
Β 
Splish Brothers Inc- began operations on July 1- It uses a perpetual i.pdf
Splish Brothers Inc- began operations on July 1- It uses a perpetual i.pdfSplish Brothers Inc- began operations on July 1- It uses a perpetual i.pdf
Splish Brothers Inc- began operations on July 1- It uses a perpetual i.pdfAlanSmDDyerl
Β 
Spinal Cord Review - Match the appropriate term to the description- Wr.pdf
Spinal Cord Review - Match the appropriate term to the description- Wr.pdfSpinal Cord Review - Match the appropriate term to the description- Wr.pdf
Spinal Cord Review - Match the appropriate term to the description- Wr.pdfAlanSmDDyerl
Β 
Soils are complex mixtures of totally inorganic materials- sterile- un.pdf
Soils are complex mixtures of totally inorganic materials- sterile- un.pdfSoils are complex mixtures of totally inorganic materials- sterile- un.pdf
Soils are complex mixtures of totally inorganic materials- sterile- un.pdfAlanSmDDyerl
Β 
So I need some python help! I'm working with a 7-segment display with.pdf
So I need some python help! I'm working with a 7-segment display with.pdfSo I need some python help! I'm working with a 7-segment display with.pdf
So I need some python help! I'm working with a 7-segment display with.pdfAlanSmDDyerl
Β 
Sketch a depositional sequence with its component parasequences- syste.pdf
Sketch a depositional sequence with its component parasequences- syste.pdfSketch a depositional sequence with its component parasequences- syste.pdf
Sketch a depositional sequence with its component parasequences- syste.pdfAlanSmDDyerl
Β 
Skeletal muscles are considered voluntary and are classified by their.pdf
Skeletal muscles are considered voluntary and are classified by their.pdfSkeletal muscles are considered voluntary and are classified by their.pdf
Skeletal muscles are considered voluntary and are classified by their.pdfAlanSmDDyerl
Β 
Shown here is a graph illustrating daty fiom the original Pulse Chase.pdf
Shown here is a graph illustrating daty fiom the original Pulse Chase.pdfShown here is a graph illustrating daty fiom the original Pulse Chase.pdf
Shown here is a graph illustrating daty fiom the original Pulse Chase.pdfAlanSmDDyerl
Β 
Since HIV has such a long window period- what implications does that h.pdf
Since HIV has such a long window period- what implications does that h.pdfSince HIV has such a long window period- what implications does that h.pdf
Since HIV has such a long window period- what implications does that h.pdfAlanSmDDyerl
Β 
Shown here is a transmission electron micrograph (TEM)- What is the mo.pdf
Shown here is a transmission electron micrograph (TEM)- What is the mo.pdfShown here is a transmission electron micrograph (TEM)- What is the mo.pdf
Shown here is a transmission electron micrograph (TEM)- What is the mo.pdfAlanSmDDyerl
Β 
Show that in general for any events E and F- Pr(EF)Pr(E)Pr(F)41.pdf
Show that in general for any events E and F- Pr(EF)Pr(E)Pr(F)41.pdfShow that in general for any events E and F- Pr(EF)Pr(E)Pr(F)41.pdf
Show that in general for any events E and F- Pr(EF)Pr(E)Pr(F)41.pdfAlanSmDDyerl
Β 
Sienna is 1 week old- Her mother- Jennifer- says that nursing is very.pdf
Sienna is 1 week old- Her mother- Jennifer- says that nursing is very.pdfSienna is 1 week old- Her mother- Jennifer- says that nursing is very.pdf
Sienna is 1 week old- Her mother- Jennifer- says that nursing is very.pdfAlanSmDDyerl
Β 
Shell script 3- (Network-sh) Network Script (Network-sh) will display.pdf
Shell script 3- (Network-sh) Network Script (Network-sh) will display.pdfShell script 3- (Network-sh) Network Script (Network-sh) will display.pdf
Shell script 3- (Network-sh) Network Script (Network-sh) will display.pdfAlanSmDDyerl
Β 

More from AlanSmDDyerl (20)

Steps to Complete for the Problem Set Step 1- SPSS spreadsheet Put the.pdf
Steps to Complete for the Problem Set Step 1- SPSS spreadsheet Put the.pdfSteps to Complete for the Problem Set Step 1- SPSS spreadsheet Put the.pdf
Steps to Complete for the Problem Set Step 1- SPSS spreadsheet Put the.pdf
Β 
STEP 7 Assess the effect of the environmental change on future generat.pdf
STEP 7 Assess the effect of the environmental change on future generat.pdfSTEP 7 Assess the effect of the environmental change on future generat.pdf
STEP 7 Assess the effect of the environmental change on future generat.pdf
Β 
Step 1- Keep it Simple To get things started- Wily Corp wants to strea.pdf
Step 1- Keep it Simple To get things started- Wily Corp wants to strea.pdfStep 1- Keep it Simple To get things started- Wily Corp wants to strea.pdf
Step 1- Keep it Simple To get things started- Wily Corp wants to strea.pdf
Β 
Starting at age 25 and continuing to age 65- Haley deposited $2000 eve.pdf
Starting at age 25 and continuing to age 65- Haley deposited $2000 eve.pdfStarting at age 25 and continuing to age 65- Haley deposited $2000 eve.pdf
Starting at age 25 and continuing to age 65- Haley deposited $2000 eve.pdf
Β 
Starting on the day Anika was born- her mother has invested $40 at the.pdf
Starting on the day Anika was born- her mother has invested $40 at the.pdfStarting on the day Anika was born- her mother has invested $40 at the.pdf
Starting on the day Anika was born- her mother has invested $40 at the.pdf
Β 
Staining a specimen for microscopy is helpful because Select one or m.pdf
Staining a specimen for  microscopy is helpful because Select one or m.pdfStaining a specimen for  microscopy is helpful because Select one or m.pdf
Staining a specimen for microscopy is helpful because Select one or m.pdf
Β 
ssume that you have been assigned the 132-45-0-0-16 network block- Ide.pdf
ssume that you have been assigned the 132-45-0-0-16 network block- Ide.pdfssume that you have been assigned the 132-45-0-0-16 network block- Ide.pdf
ssume that you have been assigned the 132-45-0-0-16 network block- Ide.pdf
Β 
spreadsheet question Philbin Financial Group titus Fund ilimmary Desin.pdf
spreadsheet question Philbin Financial Group titus Fund ilimmary Desin.pdfspreadsheet question Philbin Financial Group titus Fund ilimmary Desin.pdf
spreadsheet question Philbin Financial Group titus Fund ilimmary Desin.pdf
Β 
Splish Brothers Inc- began operations on July 1- It uses a perpetual i.pdf
Splish Brothers Inc- began operations on July 1- It uses a perpetual i.pdfSplish Brothers Inc- began operations on July 1- It uses a perpetual i.pdf
Splish Brothers Inc- began operations on July 1- It uses a perpetual i.pdf
Β 
Spinal Cord Review - Match the appropriate term to the description- Wr.pdf
Spinal Cord Review - Match the appropriate term to the description- Wr.pdfSpinal Cord Review - Match the appropriate term to the description- Wr.pdf
Spinal Cord Review - Match the appropriate term to the description- Wr.pdf
Β 
Soils are complex mixtures of totally inorganic materials- sterile- un.pdf
Soils are complex mixtures of totally inorganic materials- sterile- un.pdfSoils are complex mixtures of totally inorganic materials- sterile- un.pdf
Soils are complex mixtures of totally inorganic materials- sterile- un.pdf
Β 
So I need some python help! I'm working with a 7-segment display with.pdf
So I need some python help! I'm working with a 7-segment display with.pdfSo I need some python help! I'm working with a 7-segment display with.pdf
So I need some python help! I'm working with a 7-segment display with.pdf
Β 
Sketch a depositional sequence with its component parasequences- syste.pdf
Sketch a depositional sequence with its component parasequences- syste.pdfSketch a depositional sequence with its component parasequences- syste.pdf
Sketch a depositional sequence with its component parasequences- syste.pdf
Β 
Skeletal muscles are considered voluntary and are classified by their.pdf
Skeletal muscles are considered voluntary and are classified by their.pdfSkeletal muscles are considered voluntary and are classified by their.pdf
Skeletal muscles are considered voluntary and are classified by their.pdf
Β 
Shown here is a graph illustrating daty fiom the original Pulse Chase.pdf
Shown here is a graph illustrating daty fiom the original Pulse Chase.pdfShown here is a graph illustrating daty fiom the original Pulse Chase.pdf
Shown here is a graph illustrating daty fiom the original Pulse Chase.pdf
Β 
Since HIV has such a long window period- what implications does that h.pdf
Since HIV has such a long window period- what implications does that h.pdfSince HIV has such a long window period- what implications does that h.pdf
Since HIV has such a long window period- what implications does that h.pdf
Β 
Shown here is a transmission electron micrograph (TEM)- What is the mo.pdf
Shown here is a transmission electron micrograph (TEM)- What is the mo.pdfShown here is a transmission electron micrograph (TEM)- What is the mo.pdf
Shown here is a transmission electron micrograph (TEM)- What is the mo.pdf
Β 
Show that in general for any events E and F- Pr(EF)Pr(E)Pr(F)41.pdf
Show that in general for any events E and F- Pr(EF)Pr(E)Pr(F)41.pdfShow that in general for any events E and F- Pr(EF)Pr(E)Pr(F)41.pdf
Show that in general for any events E and F- Pr(EF)Pr(E)Pr(F)41.pdf
Β 
Sienna is 1 week old- Her mother- Jennifer- says that nursing is very.pdf
Sienna is 1 week old- Her mother- Jennifer- says that nursing is very.pdfSienna is 1 week old- Her mother- Jennifer- says that nursing is very.pdf
Sienna is 1 week old- Her mother- Jennifer- says that nursing is very.pdf
Β 
Shell script 3- (Network-sh) Network Script (Network-sh) will display.pdf
Shell script 3- (Network-sh) Network Script (Network-sh) will display.pdfShell script 3- (Network-sh) Network Script (Network-sh) will display.pdf
Shell script 3- (Network-sh) Network Script (Network-sh) will display.pdf
Β 

Recently uploaded

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
Β 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
Β 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
Β 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
Β 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)β€”β€”β€”β€”IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)β€”β€”β€”β€”IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)β€”β€”β€”β€”IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)β€”β€”β€”β€”IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
Β 
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
Β 
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
Β 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
Β 
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
Β 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
Β 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
Β 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
Β 
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
Β 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
Β 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
Β 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
Β 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
Β 

Recently uploaded (20)

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
Β 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
Β 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
Β 
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πŸ”
Β 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
Β 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)β€”β€”β€”β€”IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)β€”β€”β€”β€”IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)β€”β€”β€”β€”IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)β€”β€”β€”β€”IMP.OF KSHARA ...
Β 
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
Β 
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
Β 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
Β 
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
Β 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.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
Β 
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πŸ”
Β 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
Β 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Β 
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
Β 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Β 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
Β 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
Β 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
Β 

show code and all classes with full implementation for these Program S.pdf

  • 1. show code and all classes with full implementation for these Program Specifications. Example products ( camcorder, dvd player, blueray player, tv, camera, xbox 360, ps4, Wii, laptops, iphone, battery, smart phones, computer desktop, printer, usb, mouse) 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.
  • 2. 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.
  • 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. Testing Run the program four times to verify: The text file was loaded successfully to show the correct Inventory data. UpdateInventory will occur on the first, the middle (in this case ask for the max quantity to make restocking data to be updated to true), the last Product and non-existing product (each time your program is run select the correct or invalid product id for this to happen). Verify total cost is correct when applicable. Verify if the output text file is correct (Inventory is updated properly or the same as the original text file when entering invalid product id).