#include <iostream>
#include <string>
usingnamespace std;
class Product
{
private:
string Name; //this member will hold the name of the product
int Calories; //this will hold the calories in the product
double Price; //this will store the price of the product
double Weight; //this will store the weight of the product
public:
Product();
Product(string N, int C, double P, double W);
string GetName();
int GetCalories();
double GetPrice();
double GetWeight();
void SetName(string N);
void SetCalories(int C);
void SetPrice(double P);
void SetWeight(double W);
void Print();
};
Product::Product()
{
Name="";
Calories=0;
Price=0;
Weight=0;
}
Product::Product(string N, int C, double P, double W)
{
Name=N;
Calories=C;
Price=P;
Weight=W;
}
void Product::Print()
{
cout<<"Your product: "<<Name<<" \n\t\t\t\t Calories: "<<Calories<<" \n\t\t\t\t Price: "<<Price<<" \n\t\t\t\t Weight: "<<Weight<<endl;
}
void Product::SetName(string N)
{
Name=N;
}
void Product::SetCalories(int C)
{
Calories=C;
}
void Product::SetPrice(double P)
{
Price=P;
}
void Product::SetWeight(double W)
{
Weight=W;
}
string Product::GetName()
{
return Name;
}
int Product::GetCalories()
{
return Calories;
}
double Product::GetPrice()
{
return Calories;
}
double Product::GetWeight()
{
return Weight;
}
int main()
{
Product milk;
milk.SetName("milk");
milk.SetCalories(120);
milk.SetPrice(5.5);
milk.SetWeight(500);
Product cookies("cookies", 250, 5, 150);
cout<<"The following is the information about my products\n";
milk.Print();
cookies.Print();
if(milk.GetCalories() + cookies.GetCalories() < 1000)
cout<<"You can combine "<<milk.GetName()<<" and "<<cookies.GetName()<<" for good health";
else
cout<<"You should not combine "<<milk.GetName()<<" and "<<cookies.GetName()<<" for good health";
}
return 0;
}