Answered step by step
Verified Expert Solution
Link Copied!

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

(C++)Perform 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 13-6(consists of 13-6P.cpp, Inventory.cpp, Inventory.h, Inventory.txt, pch.h) to read in information from a file (Inventory.txt) 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: 1. Add a string variable named description to the class. a. Add supporting mutator and accessor functions. 2. 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: 1. Define an Inventory array named products to hold the inventory objects. 2. Define an integer named invItems to hold the total number of different inventory items. 3. Define an integer named invCount to hold the total number of actual inventory items. 4. Define a double named invCost to hold the total cost of all inventory items. 5. Feel free to define any work fields that you choose. 6. Define the following functions: a. Constructor i. accepts the max number of items to support CPSC-3142 Lab 3 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: 1. Define a constant in the main program named MAXITEMS and set it to 25.2. Define a Dept object named furniture and use MAXITEMS to provide the maximum inventory items it should allow. 3. Loop through the input file Inventory.txt 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: 21224034.95 Designer_Jeans 4. Call the print function of furniture to print the inventory list. 5. Print the furniture inventory item count, total inventory count, and total cost. a. Provide a descriptive printout. 6. Issue a final Program ending. message at the end of the program.
Program 13-6 Code:
13-6P.cpp
// Additional files needed to compile this program:
// Inventory.h
// Inventory.cpp
#include "pch.h"
#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 inv2(777,10,12.50);
// 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: "<< inv2.getItemNumber()<< endl;
cout << "Quantity: "<< inv2.getQuantity()<< endl;
cout << "Cost: "<< inv2.getCost()<< endl;
cout << "Total cost: "<< inv2.getTotalCost()<< endl << endl;
// Use the mutator functions to change the member values.
inv2.setItemNumber(555);
inv2.setQuantity(20);
inv2.setCost(19.95);
inv2.setTotalCost();
// Display the modified values.
cout <<"We have changed the values.
";
cout << "Here are the new values of the members:
";
cout << "Item number: "<< inv2.getItemNumber()<< endl;
cout << "Quantity: "<< inv2.getQuantity()<< endl;
cout << "Cost: "<< inv2.getCost()<< endl;
cout << "Total cost: "<< inv2.getTotalCost()<< endl << endl;
return 0;
}
Inventory.cpp:
// Implementation file for the

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

Describe your ideal working day.

Answered: 1 week ago