#include <iostream>
using namespace std;
class Product
{
private:
int PID;
int cost;
int quantity;
public:
//Default constrcuctor(i)
Product()
{
this->PID = 0;
this->cost = 0;
this->quantity = 100;
}
//(ii) Parametrazed constructor
Product(int _p, int _c, int _q)
{
this->PID = _p;
this->cost = _c;
this->quantity = _q;
}
product(){//constructor
}
~Product(){}// destructor
Product FindMaxProduct(const Product& a, const Product& b)
{
int _p = (a.PID + b.PID)/100;
int _c = (a.cost + b.cost + (a.PID + b.PID)/100) % 100;
int _q = (((a.cost + b.cost + (a.PID+ b.PID)/100)) / 100 + a.quantity + b.quantity) % 24;
return Product(_p, _c, _q);
}
void getProduct()
{
cout<<"";
}
};
int main()
{
int p, c, q,p1,q1,c1;
cout << "Please enter PID First product: ";
cin >> p;
cout << "Please enter cost First object: ";
cin >> c;
cout << "Please enter quantity First object: ";
cin >> q;
Product one(p, c, q);
cout << "Please enter PID Second object: ";
cin >> p1;
cout << "Please enter cost Second object: ";
cin >> c1;
cout << "Please enter quantity Second object: ";
cin >> q1;
Product two(p1, c1,q1);
Product th ;
th = th.FindMaxProduct(one, two);
th.getProduct();
if(q>q1){
cout<<"maximum product id is "<<p<<" and its cost is "<< "with the quantity of "<<q;}
else{
cout<<"Maximum product is "<<p1<<" and its cost is "<<c1<< "with the quantity of "<<q1;
}
//int max_Product1 = FindMaxProduct(10);
//cout << max_Product1 << endl;
return 0;
}
Comments
Leave a comment