[Solved]Modify Inventory Management System Created Previous Assignment Use Separate Container Clas Q37047905
Modify your inventory management system (created in previousassignment) to use separate container class to main the itemscollection and multiple modules to organize your code.
Previous Assignment that I submit is as follows:
//Assignment 2: Menu Driven Inventory Management System
#include <iostream>
using namespace std;
class item
{
private:
unsigned long int id[20];
string name[20];
float cost[20];
int quantity[20];
int z;
public:
void add_(void)/*add item to an inventory*/
{
cout<<“nEnter the item ID:”;
cin>>id[z];
cout<<“nEnter the item Name:”;
cin>>name[z];
cout<<“nEnter the Price of the item:”;
cin>>cost[z];
cout<<“nEnter the item Quantity:”;
cin>>quantity[z];
z++;/*to increase array pointer*/
}
void remove_(void)/*to remove from ID search and delete*/
{
int i,j,k,flag=0;
cout<<“nPlease Enter the Item ID:”;
cin>>i;
for(j=0;j<z;j++)
{
if(id[j]==i)
{
flag=1;
for(k=j;k<z-1;k++)
{
id[k]=id[k+1];
name[k]=name[k+1];
cost[k]=cost[k+1];
quantity[k]=quantity[k+1];
}
}
}
if(flag==1)
{
z=z-1;
cout<<“nThe item is deleted from the list.”;
}
else
{
cout<<“nItem Not Present”;
}
}
void display_(void)/*iterate z for displaying the list*/
{
int i;
if(z==0)
{
cout<<“nNo Items In Inventory”;
}
for(i=0;i<z;i++)
{
cout<<“nItem ID is:”<<id[i];
cout<<“nIten Name is:”<<name[i];
cout<<“nItem Price is:”<<cost[i];
cout<<“nItem Quantityis:”<<quantity[i]<<“n”;
}
}
void findbyid()/*take input id from user show the data*/
{
int i,j,flag=0;
cout<<“nPlease Enter the Item ID:”;
cin>>i;
if(z==0)
{
cout<<“nNo Items to Display.”;
}
for(j=0;j<z;j++)
{
if(id[j]==i)
{
cout<<“nItem ID is:”<<id[j];
cout<<“nItem Name is:”<<name[j];
cout<<“nItem Price is:”<<cost[j];
cout<<“nItem Quantity is:”<<quantity[j];
flag=1;
break;
}
}
if(flag==0)
{
cout<<“nItem Not Found In Inventory”;
}
}
void findbyname()/*take input item name and display it*/
{
string strname;
int i,flag=0;
cout<<“nPlease Enter the Item Name:”;
cin>>strname;
for(i=0;i<z;i++)
{
if(name[i]==strname)
{
cout<<“nItem ID is:”<<id[i];
cout<<“nItem Name is:”<<name[i];
cout<<“nItem Price is:”<<cost[i];
cout<<“nItem Quantity is:”<<quantity[i];
flag=1;
break;
}
}
if(flag==0)
{
cout<<“nItem Not Found In Inventory”;
}
}
void initial(void){z=0;}/*initially z is equal to zero*/
};
int main()
{
int i;
item shopping_mall;
shopping_mall.initial();
while(1)
{
cout<<“nInventory Management System”<<endl;
cout<<“n1: Add a new item.”;
cout<<“n2: Remove an item.”;
cout<<“n3: Print Item list.”;
cout<<“n4: Find Item by ID.”;
cout<<“n5: Find Item by Name.”;
cout<<“n6: ExitnEnter Your Choice:”;
cin>>i;
switch(i)
{
case 1:
{
shopping_mall.add_();
break;
}
case 2:
{
shopping_mall.remove_();
break;
}
case 3:
{
shopping_mall.display_();
break;
}
case 4:
{
shopping_mall.findbyid();
break;
}
case 5:
{
shopping_mall.findbyname();
break;
}
case 6:
{
cout<<“Good Bye! Thank You.”;
break;
}
}
if(i==6)
break;
}
return 0;
}
Expert Answer
Answer to Modify your inventory management system (created in previous assignment) to use separate container class to main the ite… . . .
OR

