Answered step by step
Verified Expert Solution
Question
1 Approved Answer
( C + + ) Perform the lab activities detailed in the attached file. Follow the instructions carefully: what was done in main before is
CPerform the lab activities detailed in the attached file. Follow the instructions carefully:
what was done in main before is now done within the Dept class
remember to do all processing relating to dynamic arrays
for input records with invalid values, do not process the record but display it with a message that it is invalid input.
the inventory and dept classes should be defined using their own header and cpp files as demonstrated in the video above
the default constructor can be included in the header file.
all other functions should only have a prototype in the header file.
Modify program consists of Pcpp Inventory.cpp Inventory.h Inventory.txt pchh to read in information from a file Inventorytxt to create Inventory objects that are, then, stored in an Inventory array of another object named dept for department Then, print each of the objects that comprise the departments inventory. Prefix all new fields and functions with your initials initials are dw Modifications should be made to the Inventory class as follows: Add a string variable named description to the class. a Add supporting mutator and accessor functions. Add a function named print to the class to print the following bolded letters are variable names: itemNumber description tab quantity on hand at a cost of cost for a total cost of totalCost. Create a new class named Dept with the following attributes and methods: Define an Inventory array named products to hold the inventory objects. Define an integer named invItems to hold the total number of different inventory items. Define an integer named invCount to hold the total number of actual inventory items. Define a double named invCost to hold the total cost of all inventory items. Feel free to define any work fields that you choose. Define the following functions: a Constructor i accepts the max number of items to support CPSC Lab ii dynamically allocates space for the products array iii. no default constructor offered b addItem accepts the fields needed to create an inventory object and adds the object to the furniture array. c getinvItems that calculates and returns the number of different inventory items. d getinvCount that calculates and returns the total number of actual inventory items. e getinvCost that calculates and returns the total cost of all inventory items. f printInv to print the items in the furniture array. Modifications should be made to the main program as follows: Define a constant in the main program named MAXITEMS and set it to Define a Dept object named furniture and use MAXITEMS to provide the maximum inventory items it should allow. Loop through the input file Inventorytxt and use the data in it to initialize as many items in the furniture object as the data allows. The format of data in Inventory.txt is itemNumber quantity, cost, description as follows: DesignerJeans Call the print function of furniture to print the inventory list. Print the furniture inventory item count, total inventory count, and total cost. a Provide a descriptive printout. Issue a final Program ending. message at the end of the program.
Program Code:
Pcpp
Additional files needed to compile this program:
Inventory.h
Inventory.cpp
#include pchh
#include
#include "Inventory.h
using namespace std;
int main
Define an Inventory object and use the default constructor.
Inventory inv;
Display the member values.
cout We have defined an object using the default constructor
;
cout "Here are the values of the members:
;
cout "Item number: inv.getItemNumber endl;
cout "Quantity: inv.getQuantity endl;
cout "Cost: inv.getCost endl;
cout "Total cost: inv.getTotalCost endl endl;
Define an Inventory object and use the overloaded constructor.
Inventory inv;
Display the member values.
cout We have defined an object using the overloaded constructor
;
cout "Here are the values of the members:
;
cout "Item number: invgetItemNumber endl;
cout "Quantity: invgetQuantity endl;
cout "Cost: invgetCost endl;
cout "Total cost: invgetTotalCost endl endl;
Use the mutator functions to change the member values.
invsetItemNumber;
invsetQuantity;
invsetCost;
invsetTotalCost;
Display the modified values.
cout We have changed the values.
;
cout "Here are the new values of the members:
;
cout "Item number: invgetItemNumber endl;
cout "Quantity: invgetQuantity endl;
cout "Cost: invgetCost endl;
cout "Total cost: invgetTotalCost endl endl;
return ;
Inventory.cpp:
Implementation file for the
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started