#include <iostream>
using namespace std;
// Base class
class nut
{
public:
void setType(int almond, int walnut )
{
almond ;
walnut;
}
protected:
char type;
};
class almond_butter: public nut
{
public:
string getNutrient()
{
cout<<"Protein: 30g "<<endl;
}
// Derived class
class almond: public nut
{
public:
string getType()
{
int choice;
cout<<" Choose type of nuts:"<<endl;
cout<<"1. Almond Butter"<<endl;
cout<<"2. Almond Milk"<<endl;
cin>>choice;
if(choice==1)
{
almond al;
cout<<al.getNutrient()<<endl;
}
else if(choice==2)
{
cout<<"This is the type of almond"<<endl;
cout<<" Almond Butter "<<endl;
cout<<"Characteristics: "<<endl;
cout<<"Details----------------------------------------------------------"<<endl;
cout<<"Protein: 30g "<<endl;
cout<<"Carbohydrates:28g "<<endl;
cout<<"Cholesterol: 0 "<<endl;
cout<<"Calories:60cal "<<endl;
cout<<" Almond Milk "<<endl;
cout<<"Characteristics: "<<endl;
cout<<"Details---------------------------------------------------------"<<endl;
cout<<"Protein: 20 "<<endl;
cout<<"Carbohydrates:20 "<<endl;
cout<<"Cholesterol: 0 "<<endl;
cout<<"Calories: 52 cal "<<endl;
}
else
{
cout<<"Invalid"<<endl;
}
}
};
int main(void)
{
almond al;
int choice;
cout<<" Choose type of nuts:"<<endl;
cout<<"1. Almond Butter"<<endl;
cout<<"2. Almond Milk"<<endl;
cin>>choice;
if(choice==1)
{
almond al;
cout << al.getType() << endl;
}
else if(choice==2)
{
cout<<"This is the type of almond"<<endl;
cout<<" Almond Butter "<<endl;
cout<<"Characteristics: "<<endl;
cout<<"Details----------------------------------------------------------"<<endl;
cout<<"Protein: 30g "<<endl;
cout<<"Carbohydrates:28g "<<endl;
cout<<"Cholesterol: 0 "<<endl;
cout<<"Calories:60cal "<<endl;
cout<<" Almond Milk "<<endl;
cout<<"Characteristics: "<<endl;
cout<<"Details---------------------------------------------------------"<<endl;
cout<<"Protein: 20 "<<endl;
cout<<"Carbohydrates:20 "<<endl;
cout<<"Cholesterol: 0 "<<endl;
cout<<"Calories: 52 cal "<<endl;
}
else
{
cout<<"Invalid"<<endl;
}
}
cout<< al.getType() <<endl;
return 0;
}