#include<iostream>
using namespace std;
class inventory
{
private: //private part
int item_number,quantity,cost,total_cost; //data members
public: //public part
inventory() //default constructor
{
item_number=0;
quantity=0;
cost=0;
}
inventory(int x,int y,int z) //parameterized constructor
{
item_number=x;
quantity=y;
cost=z;
}
//mamber functions
void set_item_number();
void set_quantity();
void set_cost();
void set_total_cost();
void get_item_number(int);
void get_quantity(int);
void get_cost(int);
void get_total_cost(int);
};
void inventory::get_cost(int v)
{
cost=v;
}
void inventory::get_item_number(int x)
{
item_number=x;
}
void inventory::get_quantity(int x)
{
quantity=x;
}
void inventory::get_total_cost(int y)
{
total_cost=y;
}
void inventory::set_cost()
{
cout<<"cost of the item is:"<<cost<<endl;
}
void inventory::set_item_number()
{
cout<<"the item number is:"<<item_number<<endl;
}
void inventory::set_quantity()
{
cout<<"the quantity of items is:"<<quantity<<endl;
}
void inventory::set_total_cost()
{
cout<<"the total cost will be:"<<total_cost<<endl;
}
int main()
{
int x,y,w,z;
inventory obj1,obj2(4,5,6);
cout<<"please enter the item number here:";
cin>>x;
cout<<"please enter the item quantity here:";
cin>>y;
cout<<"please enter the item cost here:";
cin>>w;
cout<<"please enter the total cost here:";
cin>>z;
obj1.get_item_number(x);
obj1.get_quantity(y);
obj1.get_cost(w);
obj1.get_total_cost(z);
cout<<endl;
obj1.set_item_number();
obj1.set_quantity();
obj1.set_cost();
obj1.set_total_cost();
}
No comments:
Post a Comment