Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Q 22 CREATE CLASS 'INVENTORY' THAE STORE ITEM NO,ITEM NAME,PRICE AND QUANTITY .
- // OVERLOAD OPRATIONS
- //UNARY + TO ADD ITEMS
- //UNARY - TO DELETE ITEMS
- // BINARY + TO INCREAMENT PRICE BY 10% FOR ITEMS HAVING PRICE LESS THEN PARTICULAR PRICE
- //DEFINE FUNCTION TO DISPLAY ALL ITEM WITH DETAILS
- #include<iostream>
- using namespace std;
- int t=-1;
- class inventory
- {
- private:
- char i_name[30];
- float price,qty;
- public:
- int i_no;
- void get_data()
- {
- cout<<"---------------------------------------------------------------";
- cout<<endl<<"Enter the item no: ";
- cin>>i_no;
- cout<<endl<<"Enter the item name: ";
- cin>>i_name;
- cout<<endl<<"Enter the item price: ";
- cin>>price;
- cout<<endl<<"Enter the item qty: ";
- cin>>qty;
- cout<<"---------------------------------------------------------------";
- }
- void put_data()
- {
- cout<<endl<<i_no<<"\t"<<i_name<<"\t"<<price<<"\t"<<qty<<"\t"<<price*qty;
- }
- void put_no()
- {
- cout<<i_no;
- }
- void operator +()
- {
- cout<<"-------------------+op overload--------------------------------";
- cout<<endl<<"Enter the item no: ";
- cin>>i_no;
- cout<<endl<<"Enter the item name: ";
- cin>>i_name;
- cout<<endl<<"Enter the item price: ";
- cin>>price;
- cout<<endl<<"Enter the item qty: ";
- cin>>qty;
- cout<<"---------------------------------------------------------------";
- }
- void operator -()
- {
- t--;
- }
- };
- int main()
- {
- inventory i[10];
- int ch;
- do
- {
- cout<<endl<<"================menu===============";
- cout<<endl<<"1.ADD";
- cout<<endl<<"2.DELETE";
- cout<<endl<<"3.increament all price by 10%";
- cout<<endl<<"4.DISPLAY";
- cout<<endl<<"5EXIT";
- cout<<"\nENter your choice: ";
- cin>>ch;
- switch(ch)
- {
- case 1:
- if(t<9)
- {
- t++;
- +i[t];
- for(int j=0;j<=t;j++)
- {
- i[j].put_data();
- }
- }
- else
- {
- cout<<endl<<"only 10 items can inserted";
- }
- break;
- case 2:
- if(t!=-1)
- {
- cout<<endl<<"*** item NO = "<<i[t].i_no<<" was deleted";
- -i[t];
- for(int j=0;j<=t;j++)
- {
- i[j].put_data();
- }
- }
- else
- {
- cout<<endl<<"Insert some Items";
- }
- break;
- case 3:
- cout<<"\nEMPTY";
- break;
- case 4:
- for(int j=0;j<=t;j++)
- {
- i[j].put_data();
- }
- break;
- }
- }while(ch>=1 && ch<=4);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement