I am currently working on a vending machine program. However, I am not able to figure out how to ask the user for input and also print out the options and prices. This is a part of my code, my question is : How can i ask the user for an input in main() and get the options from the Base subclass.
Thank you in advance.
class Product
{
protected:
string product_description;
int itemCost = 0;
public:
virtual void consume(void)
{
}
virtual int cost(void) { return this->itemCost; }
virtual string description(void) { return product_description; }
virtual Product* ReturnHighestCostItem(void)
{
return this;
}
virtual void RemoveHighestCostItem(void)
{
return;
}
};
class Base : public Product
{
public:
Base(int option)
{
if (option == 1)
{
this->product_description = "Plain";
this->itemCost = 100;
}
else if (option == 2)
{
this->product_description = "Spicy";
this->itemCost = 150;
}
else if (option == 4)
{
this->product_description = "Chocolate";
this->itemCost = 200;
}
else if (option == 8)
{
this->product_description = "Coconut";
this->itemCost = 200;
}
else if (option == 16)
{
this->product_description = "Fruity";
this->itemCost = 200;
}
}
};
int main()
{
Product obj;
cout << "The Available descriptions are:" << obj.description()<< endl;
return 0;
}