I'm making a supermarket management system based on c++ and incorporating GUI.
so, when the user enters details and all, there are four categories displayed, namely dairy products, fruits, vegetables, and cooking ingredients. When clicking on any of those, further items from the category show up. For eg, when clicked on dairy products, user can see milk, eggs, and cheese. There's "add to cart" button with all three of them.
Now I'm basically confused about the classes and filing. Firstly, I had thought that dairy products should be a parent + abstract class and have three further child classes namely milk, eggs, cheese. But that would be too many classes and not very efficient I feel. Later, I thought there should be four classes for 4 categories and an instance of class should be created everytime "add to cart" button is clicked. But im still confused on what should be the member variables of the class.. ID (because milk, cheese, eggs must have a different ID), three variables of stock (because stock count for each will be different), and name?
If anyone can help me with the basic classes, their relationships, and the member variables in it.
Thank you!
Here's the code. I'm particularly confused on how to update the stock for a particular item in a file.
#include <string>
#include <iostream>
using namespace std;
class Product
{
protected:
string name;
string ID;
int count;
Product(string n, string id, int c)
{
name=n;
ID= id;
count=c;
}
Product()
{
}
};
class FV : public Product
{
public:
FV()
{
}
FV (int a)
{
name="Apples";
ID: "APP01";
}
void UpdateStock()
{
count=count-1;
}
};