//Header File
#include<iostream>
#include<cstring>
using namespace std;
class item
{
private :
int ItemNo;
char Category[30];
int NoOfItem;
int ItemsAvailable;
public :
item(int pItemNo,const char pCategory[],int pNoOfItem,int pItemsAvailable);
void issueItem(int pItemNo,int pNoOfItem,int pItemsAvailable);
void print();
};
-------------------------------------------------------------------------------------------------------------------
//Cpp File
#include "item.h"
item::item(int pItemNo,const char pCategory[],int pNoOfItem,int pItemsAvailable)
{
ItemNo= pItemNo;
strcpy(Category,pCategory);
NoOfItem=pNoOfItem;
ItemsAvailable= pItemsAvailable;
}
void item::issueItem(int pItemNo,int pNoOfItem,int pItemsAvailable)
{
if(ItemsAvailable>=1)
{
cout<<"Item available ,can be issued"<<endl;
}
else if(ItemsAvailable<1)
{
cout<<"Item not available "<<endl;
}
else if(NoOfItem==0)
{
cout<<"Item not in Library"<<endl;
}
}
void item::print()
{
cout<<"Item no :"<<ItemNo<<endl;
cout<<"Category :"<<Category<<endl;
cout<<"No of Items :"<<NoOfItem<<endl;
cout<<"Items Available "<<ItemsAvailable<<endl;
cout<<"**************************************************************************"<<endl;
cout<<endl;
cout<<endl;
}
-------------------------------------------------------------------------------------------------------------------
//Main program
#include "item.h"
int main()
{
item i1(21001,"Book",5,2);
i1.issueItem(21001,5,2);
i1.print();
item i2(31205,"Journal",3,1);
i2.issueItem(31205,3,1);
i2.print();
item i3(89025,"Magazine",0,0);
i3.issueItem(89025,0,0);
i3.print();
return 0;
}
------------------------------------------------------------------------------------------------------------------
H.K
07.07.12
No comments:
Post a Comment