Best way to create a group of String,Double?
The example would be a pizza business that allows toppings on a certain pizza. Each pizza you buy has its own add-ons allowed, and a maximum number of add-ons from each group allowed to be added.
The String would refer to the topping description e.g. "Beef", "Sweetcorn", etc
The Double would refer to that particular toppings price.
I thought of something like the following, incorporating a Map:
is that possible? or how would you input values into Maps via parameters?
ProductModifier(Map<String, Double> modifiers...)
//should create 1 group of many modifiers
ProductModifier pm = new ProductModifier("Beef",1.00,"Sweetcorn",0.50);
or should I just go for a child class with 2 fields (one being description, the other being price) and the parent class containing a list of children with a maximum number of selections field?
(I've already created the 2nd method, but i'm not sure about it)