The second assignments is due only in C++. For this assignment you (the programm
ID: 3664401 • Letter: T
Question
The second assignments is due only in C++. For this assignment you (the programmer) were contacted by one of the online car retail stores with a request to create a car inventory management system. Unfortunately, the app will be running on a propriety mobile hardware, so the conventional database systems as a back end is out. Instead you are asked to create an object oriented inventory system for a very large inventory of vehicles. The presentation layer (that you are not responsible for implementing) will be a browser that the customer and managers use to search for different types of vehicles by make, by engine type, and by carrying capacity. In addition to these search features, your app will have to support deletion and addition of vehicle inventory. The initial data load will be from a tab delimited text file – this is the only section of the code that you are allowed to use tokenizer to parse individual lines of text to create objects.
Methodology:
Each vehicle will be an object of Vehicle type with the following slots: int::id, string::make, string::model, char::engineType (D:diesel, G:gas, H:hybrid,E:electric), int::carryingCapacity, 0-5::customerRating. To keep track of the vehicles and support the search functionality of your application, you need to create 4 linked lists. The first one will keep track of all vehicles (allVehicles) and will be search-able by id, the reminder 3 lists will be skip-lists where objects will be inserted in order and search-able byMake, byEngineType,byCarryingCapacity (in 100 lbs increment steps – input example 735 means search for all engines 735-835lbs). The add function will contain 6 values for each object, and the delete command will be followed by an id of an object to be deleted. The final command is t for terminate the application.
Design note: You might consider each vehicle object to have an internal linked list to the SkipListNode objects for the ease of implementing the delete function. The problem is if you delete a vehicle object, first locate the vehicle using the allVehicles LList, but if you delete the object, it is still being pointed to by the other SkipListNodes. One option, is to search all other link lists to delete the individual SkipListNodes inbyMake, byEngineType, byCarryingCapacity OR have a doubly linked lists in each vehicle object that point to the individual SkipListNodes to be deleted.
Commands to the API:
byMake string
byEngineType (D|G|H|E)
byCarryingCapacity int
add int::id string::make string::model char::engineType int::carryingCapacity 0-5::customerRating
delete int
Example:
example.txt
1 ford escort G 750 2
2 ford mustang G 920 4
3 ford scorpion G 710 3
4 subaru outback G 950 5
5 subaru impreza D 875 4
6 subaru forrester G 980 3
7 ford T G 510 5
8 ford F-150 D 1250 4
9 ford F-350 D 1500 3
10 ford F-150 G 1050 2
11 ford F-350 G 1200 4
12 ford F-150 H 950 5
13 ford F-350 H 1100 4
>> byMake subaru
<<4 subaru outback G 950 5
<<5 subaru impreza G 875 4
<<6 subaru forrester G 980 3
>> byEngineType D
<<8 ford F-150 D 1250 4
<<9 ford F-350 D 1500 3
<<5 subaru impreza D 875 4
>> byCarryingCapacity 910
<<2 ford mustang G 920 4
<<4 subaru outback G 950 5
<<6 subaru forrester G 980 3
<<13 ford F-350 H 1100 4
>>delete 10
<<deleted: 10 ford F-150 G 1050 2
>> delete: 12
<< not found id 12
>> add 16 subaru baha h 972 2
<< added 16 subaru baha h 972 2
>> add 9 ford F-350 D 1500 3
<< could not add: duplicate id
Design:
Implement the following functionality of the UJS:
Implementation in C++
You cannot use built-in libraries, only tokenizer for parsing in the input
Read-in unlimited number of vehicles (NO ARRAYS)
Implement all necessary setter, getter, and manipulation methods
Allocate all data-structures on the heap (not the stack)
Graceful termination: deallocate all allocated memory before exiting the application
Explanation / Answer
Inventory management system which provides below functionalities.
1) Add item
2) Display stock
3) Search item
4) Update item information
5) Delete item information
6) Analysis of stock
#include <conio.h>
#include <iostream.h>
#include <process.h>
#include <fstream.h>
#include <dos.h>
#include <stdio.h>
#include <string.h>
class shop
{
private:
int itno,alrt,no;double cost;char name[50];
public:
void getd()
{
clrscr();
cout<<“Enter Item Code:”;
textbackground(4);cprintf(” “);
gotoxy(17,1);cin>>itno;
gotoxy(17,1);textbackground(0);
cprintf(” “);
gotoxy(17,1);cout<<itno<<endl;
cout<<endl<<“Enter Item Name:”;
textbackground(4);
cprintf(” “);
gotoxy(17,3);gets(name);
gotoxy(17,3);textbackground(0);
cprintf(” “);
gotoxy(17,3);cout<<name<<endl;
cout<<endl<<“Enter Cost:”;
textbackground(4);cprintf(” “);
gotoxy(12,5);cin>>cost;
gotoxy(12,5);textbackground(0);
cprintf(” “);
gotoxy(12,5);cout<<cost<<endl;
cout<<endl<<“Enter Number of Pieces Purchased:”;
textbackground(4);cprintf(” “);
gotoxy(34,7);cin>>no;
gotoxy(34,7);textbackground(0);
cprintf(” “);
gotoxy(34,7);cout<<no<<endl;
cout<<endl<<“Enter Low Reserve Alert:”;
textbackground(4);cprintf(” “);
gotoxy(25,9);cin>>alrt;
gotoxy(25,9);textbackground(0);
cprintf(” “);
gotoxy(25,9);cout<<alrt;
}
void showd()
{
cout<<endl;
cout<<“Item No.:”;cout<<itno;
cout<<endl<<“Item Name:”;puts(name);
cout<<“Cost:”<<cost;
cout<<endl<<“No. of pieces in stock:”<<no;
cout<<endl<<“Low Reserve alert:”<<alrt;
}
double retcost()
{return (cost);}
int retitno()
{return (itno);}
int retno()
{return (no);}
int retalrt()
{return (alrt);}
char *retname()
{return (name);}
void putno(int a)
{no+=a;}
void remno(int a)
{no-=a;}
void splshow(int line)
{
gotoxy(3,line);cout<<itno;
gotoxy(10,line);cout<<name;
gotoxy(34,line);cout<<” “<<cost;
gotoxy(50,line);cout<<no;
gotoxy(63,line);cout<<alrt;
}
}s1;
//**************************************************************************
//***********************Function For Main
Menu*****************************
//**************************************************************************
char mmenu()
{
textbackground(0);clrscr();
int chno=1;char chkcho=’1;
_setcursortype(_NOCURSOR);
char a;clrscr();cout<<“a”;
for (int i=15;i<60;i++) //top horizontal
{
gotoxy(i, 3);
if (i%2==0)
{textcolor(3);cprintf(“*”);}
else
{textcolor(4);cprintf(“*”);}
}
for (int y=4;y<20;y++) //left vertical
{
gotoxy(15,y);
if (y%2==0)
{textcolor(3);cprintf(“*”);}
else
{textcolor(4);cprintf(“*”);}
}
for (int t=4;t<20;t++) //right vertical
{
gotoxy(59,t);
if (t%2==0)
{textcolor(3);cprintf(“*”);}
else
{textcolor(4);cprintf(“*”);}
}
for (int g=15;g<60;g++)
{
gotoxy(g,19);
if (g%2==0)
{textcolor(3);cprintf(“*”);}
else
{textcolor(4);cprintf(“*”);}
}
for (int u=15;u<60;u++) //middle horizontal
{
gotoxy(u,7);
if (u%2==0)
{textcolor(3);cprintf(“*”);}
else
{textcolor(4);cprintf(“*”);}
}
gotoxy(1,1);textcolor(3);
cprintf(” *****THE MALL*****”);
gotoxy(40,21);cprintf(“S.C.F. 136,Karol Bagh”);
gotoxy(40,22);cprintf(“New Delhi”);
gotoxy(40,23);cprintf(“Phone:91-6633771/72/73,9811223344”);
gotoxy(33,5);cprintf(“Main Menu”);
gotoxy(1,21);cout<<“‘<‘=Up
‘>’=Down
Enter=Select
Crtl+X=Exit”;
gotoxy(17,9);cprintf(“(1.)MODIFY INVENTORY.”);
textbackground(0);
fstream k;
k.open(“master.dat”,ios::in);
while (k.read((char*)&s1,sizeof(s1)))
if (s1.retno()<=s1.retalrt())
textcolor(5);
k.close();
gotoxy(17,11);cprintf(“(2.)ORDER NEW STOCK.”);textcolor(3);
gotoxy(17,13);cprintf(“(3.)SALE VOUCHER.”);
gotoxy(17,15);cprintf(“(4.)SEARCH FOR PARTICULAR ITEM.”);
gotoxy(17,17);cprintf(“(5.)Exit.”);
gotoxy (40,17);
char ch;textbackground(4);
gotoxy(17,9);cprintf(” “);
gotoxy(17,9);cout<<“(1.)MODIFY INVENTORY.”;
x:
a=getch();
if (a==46 && chno==1) // 1 to 2
{
chkcho=’2;chno=2;
gotoxy(17,9);textbackground(0);
cprintf(” “);
gotoxy(17,9);cout<<“(1.)MODIFY INVENTORY.”;
gotoxy(17,11);textbackground(4);
cprintf(” “);
gotoxy(17,11);cout<<“(2.)ORDER NEW STOCK.”;
goto x;
}
if (a==46 && chno==2) //2 to 3
{
chkcho=’3;chno=3;
gotoxy(17,11);textbackground(0);
cprintf(” “);
gotoxy(17,11);cout<<“(2.)ORDER NEW STOCK.”;
gotoxy(17,13);cout<<“(3.)SALE VOUCHER.”;
gotoxy(17,13);textbackground(4);
cprintf(” “);
gotoxy(17,13);cout<<“(3.)SALE VOUCHER.”;
goto x;
}
if (a==46 && chno==3) //3 to 4
{
chkcho=’4;chno=4;
gotoxy(17,13);textbackground(0);
cprintf(” “);
gotoxy(17,13);cout<<“(3.)SALE VOUCHER.”;
gotoxy(17,13);cout<<“(3.)SALE VOUCHER.”;
gotoxy(17,15);textbackground(4);
cprintf(” “);
gotoxy(17,15);cout<<“(4.)SEARCH FOR PARTICULAR ITEM.”;
goto x;
}
if (a==46 && chno==4) //4 to 5
{
chkcho=’5;chno=5;
gotoxy(17,15);textbackground(0);
cprintf(” “);
gotoxy(17,15);cout<<“(4.)SEARCH FOR PARTICULAR ITEM.”;
gotoxy(17,15);cout<<“(4.)SEARCH FOR PARTICULAR ITEM.”;
gotoxy(17,17);textbackground(4);
cprintf(” “);
gotoxy(17,17);cout<<“(5.)Exit”;
goto x;
}
if (a==44 && chno==5) // 5 to 4
{
chno=4; chkcho=’4;
gotoxy(17,17);textbackground(0);
cprintf(” “);
gotoxy(17,17);cout<<“(5.)Exit.”;
gotoxy(17,15);textbackground(4);
cprintf(” “);
gotoxy(17,15);cout<<“(4.)SEARCH FOR PARTICULAR ITEM.”;
goto x;
}
if (a==44 && chno==4) //4 to 3
{
chno=3;chkcho=’3;
gotoxy(17,15);textbackground(0);
cprintf(” “);
gotoxy(17,15);cout<<“(4.)SEARCH FOR PARTICULAR ITEM.”;
gotoxy(17,13);
textbackground(4);
cprintf(” “);
gotoxy(17,13);cout<<“(3.)SALE VOUCHER.”;
goto x;
}
if (a==44 && chno==3) //3 to 2
{
chno=2; chkcho=’2;
gotoxy(17,13);textbackground(0);
cprintf(” “);
gotoxy(17,13);cout<<“(3.)SALE VOUCHER.”;
gotoxy(17,11);textbackground(4);
cprintf(” “);
gotoxy(17,11);cout<<“(2.)ORDER NEW STOCK.”;
goto x;
}
if (a==44 && chno==2) //2 to 1
{
chno=1;chkcho=’1;
gotoxy(17,11);textbackground(0);
cprintf(” “);
gotoxy(17,11);cprintf(“(2.)ORDER NEW STOCK.”);
gotoxy(17,9);textbackground(4);
cprintf(” “);
gotoxy(17,9);cprintf(“(1.)MODIFY INVENTORY.”);
goto x;
}
if (a==46 && chno==5) //5 to 1
{
chno=1;chkcho=’1;
gotoxy(17,17);textbackground(0);
cprintf(” “);
gotoxy(17,17);cprintf(“(5.)Exit.”);
gotoxy(17,9);textbackground(4);
cprintf(” “);
gotoxy(17,9);cprintf(“(1.)MODIFY INVENTORY.”);
goto x;
}
if (a==44 && chno==1) //1 to 5
{
chno=5;chkcho=’5;
gotoxy(17,9);textbackground(0);
cprintf(” “);
gotoxy(17,9);cprintf(“(1.)MODIFY INVENTORY.”);
gotoxy(17,17);textbackground(4);
cprintf(” “);
gotoxy(17,17);cprintf(“(5.)Exit.”);
goto x;
}
textbackground(0);
if (a==24)exit(0);
if (a==13)return chkcho;
}
//**************************************************************************
//***********************Function For Search
Menu***************************
//**************************************************************************
char smenu()
{
textbackground(0);clrscr();
int chno=1;char chkcho=’1’;
_setcursortype(_NOCURSOR);
char a;clrscr();cout<<“a”;
for (int i=15;i<60;i++) //top horizontal
{
gotoxy(i, 3);
if (i%2==0)
{textcolor(3);cprintf(“*”);}
else
{textcolor(4);cprintf(“*”);}
}
for (int y=4;y<20;y++) //left vertical
{
gotoxy(15,y);
if (y%2==0)
{textcolor(3);cprintf(“*”);}
else
{textcolor(4);cprintf(“*”);
}
}
for (int t=4;t<20;t++) //right vertical
{
gotoxy(59,t);
if (t%2==0)
{textcolor(3);cprintf(“*”);}
else
{textcolor(4);cprintf(“*”);}
}
for (int g=15;g<60;g++) //bottom horizontal
{
gotoxy(g,19);
if (g%2==0)
{textcolor(3);cprintf(“*”);}
else
{textcolor(4);cprintf(“*”);}
}
for (int u=15;u<60;u++) //middle horizontal
{
gotoxy(u,7);
if (u%2==0)
{textcolor(3);cprintf(“*”);}
else
{textcolor(4);cprintf(“*”);}
}
gotoxy(1,1);textcolor(3);
cprintf(” *****THE MALL*****”);
gotoxy(40,21);cprintf(“S.C.F. 136,Karol Bagh”);
gotoxy(40,22);cprintf(“New Delhi”);
gotoxy(40,23);cprintf(“Phone:91-6633771/72/73,9811223344”);
gotoxy(33,5);cprintf(“Search Menu”);
gotoxy(1,21);cout<<“‘<‘=Up
‘>’=Down
Enter=Select
Crtl+X=Exit”;
gotoxy(17,9);cprintf(“(1.)Search using item code.”);
textbackground(0);
gotoxy(17,11);cprintf(“(2.)Search using item name.”);
gotoxy(17,13);cprintf(“(3.)List all items in stock.”);
gotoxy(17,15);cprintf(“(4.)Print last sale voucher.”);
gotoxy(17,17);cprintf(“(5.)Return to main menu.”);
gotoxy(40,17);char ch;textbackground(4);
gotoxy(17,9);
cprintf(” “);
gotoxy(17,9);cprintf(“(1.)Search using item code.”);
x:
a=getch();
if (a==46 && chno==1) // 1 to 2
{
chkcho=’2;chno=2;
gotoxy(17,9);textbackground(0);
cprintf(” “);
gotoxy(17,9);cout<<“(1.)Search using item code.”;
gotoxy(17,11);textbackground(4);
cprintf(” “);
gotoxy(17,11);cout<<“(2.)Search using item name.”;
goto x;
}
if (a==46 && chno==2) //2 to 3
{
chkcho=’3;chno=3;
gotoxy(17,11);textbackground(0);
cprintf(” “);
gotoxy(17,11);cout<<“(2.)Search using item name.”;
gotoxy(17,13);cout<<“(3.)List all items in stock.”;
gotoxy(17,13);textbackground(4);
cprintf(” “);
gotoxy(17,13);cout<<“(3.)List all items in stock.”;
goto x;
}
if (a==46 && chno==3) //3 to 4
{
chkcho=’4;chno=4;
gotoxy(17,13);textbackground(0);
cprintf(” “);
gotoxy(17,13);cout<<“(3.)List all items in stock.”;
gotoxy(17,13);cout<<“(3.)List all items in stock.”;
gotoxy(17,15);textbackground(4);
cprintf(” “);
gotoxy(17,15);cout<<“(4.)Print last sale voucher.”;
goto x;
}
if (a==46 && chno==4) //4 to 5
{
chkcho=’5;chno=5;
gotoxy(17,15);textbackground(0);
cprintf(” “);
gotoxy(17,15);cout<<“(4.)Print last sale voucher.”;
gotoxy(17,15);cout<<“(4.)Print last sale voucher.”;
gotoxy(17,17);textbackground(4);
cprintf(” “);
gotoxy(17,17);cout<<“(5.)Return to main menu”;
goto x;
}
if (a==44 && chno==5) // 5 to 4
{
chno=4;chkcho=’4;
gotoxy(17,17);textbackground(0);
cprintf(” “);
gotoxy(17,17);cout<<“(5.)Return to main menu.”;
gotoxy(17,15);textbackground(4);
cprintf(” “);
gotoxy(17,15);cout<<“(4.)Print last sale voucher.”;
goto x;
}
if (a==44 && chno==4) //4 to 3
{
chno=3;chkcho=’3;
gotoxy(17,15);textbackground(0);
cprintf(” “);
gotoxy(17,15);cout<<“(4.)Print last sale voucher.”;
gotoxy(17,13);textbackground(4);
cprintf(” “);
gotoxy(17,13);
cout<<“(3.)List all items in stock.”;
goto x;
}
if (a==44 && chno==3) //3 to 2
{
chno=2;chkcho=’2;
gotoxy(17,13);textbackground(0);
cprintf(” “);
gotoxy(17,13);cout<<“(3.)List all items in stock.”;
gotoxy(17,11);textbackground(4);
cprintf(” “);
gotoxy(17,11);cout<<“(2.)Search using item name.”;
goto x;
}
if (a==44 && chno==2) //2 to 1
{
chno=1; chkcho=’1;
gotoxy(17,11);textbackground(0);
cprintf(” “);
gotoxy(17,11);cprintf(“(2.)Search using item name.”);
gotoxy(17,9);textbackground(4);
cprintf(” “);
gotoxy(17,9);cprintf(“(1.)Search using item code.”);
goto x;
}
if (a==46 && chno==5) //5 to 1
{
chno=1;chkcho=’1;
gotoxy(17,17);textbackground(0);
cprintf(” “);
gotoxy(17,17);cprintf(“(5.)Return to main menu.”);
gotoxy(17,9);textbackground(4);
cprintf(” “);
gotoxy(17,9);cprintf(“(1.)Search using item code.”);
goto x;
}
if (a==44 && chno==1) //1 to 5
{
chno=5;chkcho=’5;
gotoxy(17,9);textbackground(0);
cprintf(” “);
gotoxy(17,9);cprintf(“(1.)Search using item code.”);
gotoxy(17,17);textbackground(4);
cprintf(” “);
gotoxy(17,17);cprintf(“(5.)Return to main menu.”);
goto x;
}
textbackground(0);
if (a==24)
{exit(0);}
if (a==13)
{return chkcho;}
}
//**************************************************************************
//***********************Function For Modifying
Inventory*******************
//**************************************************************************
char inven()
{
textbackground(0);clrscr();
int chno=1;char chkcho=’1’;_setcursortype(_NOCURSOR);
char a;clrscr();cout<<“a”;
for (int i=15;i<60;i++) //top horizontal
{
gotoxy(i, 3);
if (i%2==0)
{textcolor(3);cprintf(“*”);
}
else
{textcolor(4);cprintf(“*”);}
}
for (int y=4;y<20;y++) //left vertical
{
gotoxy(15,y);
if (y%2==0)
{textcolor(3);cprintf(“*”);}
else
{textcolor(4);cprintf(“*”);}
}
for (int t=4;t<20;t++) //right vertical
{
gotoxy(59,t);
if (t%2==0)
{textcolor(3);cprintf(“*”);
}
else
{textcolor(4);cprintf(“*”);}
}
for (int g=15;g<60;g++) //bottom horizontal
{
gotoxy(g,19);
if (g%2==0)
{textcolor(3);cprintf(“*”);}
else
{textcolor(4);cprintf(“*”);}
}
for (int u=15;u<60;u++) //middle horizontal
{
gotoxy(u,7);
if (u%2==0)
{textcolor(3);cprintf(“*”);}
else
{textcolor(4);cprintf(“*”);}
}
gotoxy(1,1);textcolor(3);
cprintf(” *****THE MALL*****”);
gotoxy(40,21);cprintf(“S.C.F. 136,Karol Bagh”);
gotoxy(40,22);cprintf(“New Delhi”);
gotoxy(40,23);cprintf(“Phone:91-6633771/72/73,9811223344”);
gotoxy(33,5);cprintf(“Modify Inventory”);
gotoxy(1,21);cout<<“‘<‘=Up
‘>’=Down
Enter=Select
Crtl+X=Exit”;
gotoxy(17,9);cprintf(“(1.)Add item.”);textbackground(0);
gotoxy(17,11);cprintf(“(2.)Delete item.”);
gotoxy(17,13);cprintf(“(3.)Modify existing item.”);
gotoxy(17,15);cprintf(“(4.)Return to main menu.”);
gotoxy(17,17);char ch;textbackground(4);gotoxy(17,9);
cprintf(” “);
gotoxy(17,9);cprintf(“(1.)Add item.”);
x:
a=getch();
if (a==46 && chno==1) // 1 to 2
{
chkcho=’2;chno=2;
gotoxy(17,9);textbackground(0);
cprintf(” “);
gotoxy(17,9);cout<<“(1.)Add item.”;
gotoxy(17,11);textbackground(4);
cprintf(” “);
gotoxy(17,11);cout<<“(2.)Delete item.”;
goto x;
}
if (a==46 && chno==2) //2 to 3
{
chkcho=’3;chno=3;
gotoxy(17,11);textbackground(0);
cprintf(” “);
gotoxy(17,11);cout<<“(2.)Delete item.”;
gotoxy(17,13);cout<<“(3.)Modify existing item.”;
gotoxy(17,13);textbackground(4);
cprintf(” “);
gotoxy(17,13);cout<<“(3.)Modify existing item.”;
goto x;
}
if (a==46 && chno==3) //3 to 4
{
chkcho=’4;chno=4;
gotoxy(17,13);textbackground(0);
cprintf(” “);
gotoxy(17,13);
cout<<“(3.)Modify existing item.”;
gotoxy(17,13);
cout<<“(3.)Modify existing item.”;
gotoxy(17,15);
textbackground(4);
cprintf(” “);
gotoxy(17,15);
cout<<“(4.)Return to main menu.”;
goto x;
}
if (a==44 && chno==4) //4 to 3
{
chno=3;chkcho=’3;
gotoxy(17,15);textbackground(0);
cprintf(” “);
gotoxy(17,15);cout<<“(4.)Return to main menu.”;
gotoxy(17,13);textbackground(4);
cprintf(” “);
gotoxy(17,13);cout<<“(3.)Modify existing item.”;
goto x;
}
if (a==44 && chno==3) //3 to 2
{
chno=2;chkcho=’2;
gotoxy(17,13);textbackground(0);
cprintf(” “);
gotoxy(17,13);cout<<“(3.)Modify existing item.”;
gotoxy(17,11);textbackground(4);
cprintf(” “);
gotoxy(17,11);cout<<“(2.)Delete item.”;
goto x;
}
if (a==44 && chno==2) //2 to 1
{
chno=1;chkcho=’1;
gotoxy(17,11);textbackground(0);
cprintf(” “);
gotoxy(17,11);cprintf(“(2.)Delete item.”);
gotoxy(17,9);textbackground(4);
cprintf(” “);
gotoxy(17,9);cprintf(“(1.)Add item.”);
goto x;
}
if (a==46 && chno==4) //4 to 1
{
chno=1; chkcho=’1;gotoxy(17,15);textbackground(0);
cprintf(” “);
gotoxy(17,15);cprintf(“(4.)Return to main menu.”);
gotoxy(17,9);textbackground(4);
cprintf(” “);
gotoxy(17,9);cprintf(“(1.)Add item”);
goto x;
}
if (a==44 && chno==1) //1 to 4
{
chno=4;chkcho=’4’;
gotoxy(17,9);textbackground(0);
cprintf(” “);
gotoxy(17,9);cprintf(“(1.)Add item.”);
gotoxy(17,15);textbackground(4);
cprintf(” “);
gotoxy(17,15);cprintf(“(4.)Return to main menu.”);
goto x;
}
textbackground(0);
if (a==24)
{exit(0);}
if (a==13)
{return chkcho;}
}
void main()
{ clrscr();_setcursortype(_NOCURSOR); clrscr();
textbackground(3);
textcolor(4);
for (int i=1;i<24;i++)
{clrscr();gotoxy(i,1);cprintf(“Inventory Management System”);
delay(100);}
for (int o=2;o<7;o++)
{clrscr();
gotoxy(23,o);cout<<“Inventory Management System”;delay(100);
}delay(1000);
gotoxy(33,9);cout<<“Made By:-“;delay (1000);
gotoxy(31,11);cout<<“Vaibhav Kaul”;delay(1000);
gotoxy(32,13);cout<<“Class XII-C”;delay(1000);
gotoxy(22,15);cout<<“DELHI PUBLIC SCHOOL,VASANT KUNJ”;delay(3000);
char choice,schoice;shop s1;char f;fstream vai,temp;clrscr();
choice=mmenu();
a:
switch(choice)
{
case (‘1):
b:
char incho=inven();
if (incho==’1)
{
vai.open(“master.dat”,ios::app);
char add;
do
{
s1.getd();
vai.write((char*)&s1,sizeof(s1));
cout<<”
Would you like to add another item(y/n):”;
cin>>add;
}while(add==’y’ || add==’Y’);
vai.close();
cout<<”
Inventory Updated.”;
delay (1000);
goto b;
}
else if (incho==’2)
{
clrscr();int count;
vai.open(“master.dat”,ios::in);
temp.open(“temp.dat”,ios::out);
cout<<“Enter the Item No. to be deleted:”;int n;
cin>>n;
while(vai.read((char*)&s1,sizeof(s1)))
{
if (s1.retitno()!=n)
temp.write((char*)&s1,sizeof(s1));
}
vai.close();temp.close();
vai.open(“master.dat”,ios::out);
temp.open(“temp.dat”,ios::in);
while(temp.read((char*)&s1,sizeof(s1)))
vai.write((char*)&s1,sizeof(s1));
vai.close();temp.close();
cout<<”
Record deleted”;delay (1000);goto b;
}
else if (incho==’3)
{
clrscr();
vai.open(“master.dat”,ios::ate|ios::out|ios::in);
int n;
cout<<”
Enter Item Number to be modefied:”;cin>>n;
clrscr() ;
cout<<”
Enter The Modified record….
“;
delay(2000);
s1.getd();
int loc=(n-1)*(sizeof(s1));
vai.seekp(loc,ios::beg);
vai.write((char*)&s1,sizeof(s1));
vai.close();
cout<<”
Record Modified”;
delay(1000);
goto b;
}
else if (incho==’4)
{
choice=mmenu();goto a;
}
else
{
clrscr();
goto b;
}
case ‘2’:
clrscr();
cout<<“Items which need attention”;
vai.open(“master.dat”,ios::in);
int flag=0;
while(vai.read((char*)&s1,sizeof(s1)))
{
if (s1.retalrt()>=s1.retno())
{ flag=1;int z=s1.retitno(),x=s1.retno();
cout<<endl<<“Item No.:”<<z;
cout<<“Name:”;cout<<s1.retname();
cout<<”
No. of pieces in stock:”<<x;
cout<<endl;
}
}
vai.close();
if (flag==1)
{
do
{cout<<endl<<“Enter Item no. to be ordered:”;int t;cin>>t;
cout<<”
Enter No. of pieces to be ordered:”;int y;cin>>y;
vai.open(“master.dat”,ios::in);
temp.open(“temp.dat”,ios::out);
while(vai.read((char*)&s1,sizeof(s1)))
{
if (t==s1.retitno())
{
s1.putno(y);
}
temp.write((char*)&s1,sizeof(s1));
}
vai.close();temp.close();
vai.open(“master.dat”,ios::out);
temp.open(“temp.dat”,ios::in);
while(temp.read((char*)&s1,sizeof(s1)))
{
vai.write((char*)&s1,sizeof(s1));
}
vai.close();temp.close();
cout<<”
Do you want to order more(y/n):”;cin>>f;
}while(f==’y’ || f==’Y’);
}
else
{
gotoxy(25,10);cout<<“There are no items in this view”;
delay(2000);
choice=mmenu();
goto a;
}
choice=mmenu();
goto a;
case ‘3’:
clrscr();
cout<<“Item No. Name Cost Quantity Total Buy
More(Y/N)
“;
ofstream bill(“bill.dat”);
bill<<” SALE VOUCHER”;
bill<<”
S.C.F. 136 Karol Bagh,
New Delhi.”;
bill<<” Phone:91-6633771/72/73,9811223344;
bill<<”
Item No. Name Cost Qty Total”;
int n,q,line=1,qty=0;double c;long double gt=0;
char *s,print,g;
do
{
z:
qty++;line++;
textbackground(4);gotoxy(1,line);cprintf(” “);
gotoxy(1,line);cin>>n;
gotoxy(1,line);textbackground(0);
cprintf(” “);gotoxy(1,line);cout<<n;
vai.open(“master.dat”,ios::in);
temp.open(“temp.dat”,ios::out);
while(vai.read((char*)&s1,sizeof(s1)))
{
if (n==s1.retitno())
{
s=s1.retname(); gotoxy(10,line);
textbackground(4);
cprintf(” “);
gotoxy(10,line);cout<<s;getch();
gotoxy(10,line);textbackground(0);
cprintf(” “);
gotoxy(10,line);cout<<s;gotoxy(28,line);
textbackground(4);cprintf(” “);
gotoxy(28,line);cout<<s1.retcost();getch();
gotoxy(28,line);textbackground(0);
cprintf(” “);gotoxy(28,line);
cout<<s1.retcost();
gotoxy(39,line);textbackground(4);
cprintf(” “);
gotoxy(39,line);cin>>q;gotoxy(39,line);
textbackground(0);cprintf(” “);
gotoxy(39,line);cout<<q;s1.remno(q);
gotoxy(51,line);textbackground(4);
cprintf(” “);gotoxy(51,line);
cout<<s1.retcost()*q;
getch();gotoxy(51,line);
textbackground(0);
cprintf(” “);
gotoxy(51,line);cout<<s1.retcost()*q;
long double total; char *s;
s=s1.retname();total=s1.retcost()*q;
gt+=total;
bill<<endl<<” “<<n<<” “;bill<<” “<<s;
bill<<” “<<s1.retcost()<<” “<<q<<” “<<” “<<total;
gotoxy(66,line);textbackground(4);cprintf(” “);
gotoxy(66,line);
}
temp.write((char*)&s1,sizeof(s1));
}
vai.close();temp.close();
vai.open(“master.dat”,ios::out);
temp.open(“temp.dat”,ios::in);
while(temp.read((char*)&s1,sizeof(s1)))
{
vai.write((char*)&s1,sizeof(s1));
}
vai.close();temp.close();
cin>>g;gotoxy(66,line);
textbackground(0);cprintf(” “);
gotoxy(66,line);cout<<g;
}while(g==’y’ || g==’y’);
bill<<”
–x—-“;
bill<<”
Total Qty=”<<qty<<” “<<“Grand Total=”<<gt;
bill.close();clrscr();
ifstream bil(“bill.dat”);
while (!(bil.eof()))
{print=bil.get();cout<<print;}
bil.close();
cout<<”
Press any key to go back……”;
getch();choice=mmenu();goto a;
case ‘4’: c:
schoice=smenu();
if (schoice==’1)
{ vai.open(“master.dat”,ios::in);
int u;clrscr();
cout<<“Enter Item Code:”;cin>>u;
int flag=0;
while(vai.read((char*)&s1,sizeof(s1)))
{
if (u==s1.retitno())
{
flag=1;
s1.showd();
}}if (flag==0) cout<<endl<<“Item Not Found”;
vai.close();
cout<<”
Press any key to continue…..”;
getch();
goto c;
}
else if(schoice==’2)
{ vai.open(“master.dat”,ios::in);
char u[25];clrscr();
cout<<“Enter Item Name:”;gets(u);
int flag=0;
while(vai.read((char*)&s1,sizeof(s1)))
{
if (strcmpi(u,s1.retname())==0)
{flag=1;s1.showd();}
}
if (flag==0)
cout<<”
Not Found.”;
vai.close();
cout<<”
Press any key to continue…..”;
getch();goto c;
}
else if (schoice==’3)
{
clrscr();
gotoxy(1,1);cout<<“Item No”;
gotoxy(10,1);cout<<“Name”;
gotoxy(35,1);cout<<“Cost”;
gotoxy(50,1);cout<<“Stock”;
gotoxy(60,1);cout<<“Alert Level”;
vai.open(“master.dat”,ios::in);
int count=1,w=0;
while(vai.read((char*)&s1,sizeof(s1)))
{
q:
w++;
if (w<=9)
{ count+=2;s1.splshow(count); }
else
{
w=0,count=1;
cout<<”
Press any key for more….”;
getch();clrscr();
gotoxy(1,1);cout<<“Item No”;
gotoxy(10,1);cout<<“Name”;
gotoxy(35,1);cout<<“Cost”;
gotoxy(50,1);cout<<“Stock”;
gotoxy(60,1);cout<<“Alert Level”;
goto q;
}
}
vai.close();
cout<<”
Press any key to go back………..”;
getch();goto c;
}
else if (schoice==’4)
{
char f;clrscr();
ifstream bil(“bill.dat”);
char print;
while (!(bil.eof()))
{print=bil.get();cout<<print;}
bil.close();cout<<”
Press any key to return……”;
getch();goto c;
}
else if (schoice==’5)
{ choice=mmenu();goto a; }
else goto c;
case ‘5’:exit(0);
default :choice=mmenu();goto a;
}
}