Hello,
I am working on a game where I want to have shop items.
I want these values to be accessible to any class I want to include them in without making a new object of type ShopItems for example.
The shop items are all custom types and therefor an array of simply initializing them won't work. I was thinking something in the lines of a CSV file or anywhere where I could just say something like this:
Food,Chicken,20,5
Where Food would be the item's class name, Chicken the name of an item(string) and 20 the price of the item. The classes (Food, blabla) all extend from a super class ShopElement which has just 2 variables - Name and price. So any value after the price ( <Class>,<name>,<price>,... ) would be a parameter to that specific class. Example constructor:
|
Food(std::string name, int price, std::string weight):ShopElement(name,price)
|
Just making new elements in the form
new Food("Chicken", 20, 5)
is also very convenient but I have not found a way to achieve anything that way.
What is the simplest and most appropriate method to do this?
Thank you for your time,
suzi9spal