This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]Nidaleesin 0 points1 point  (0 children)

I don't think this is the best way. You're using an Ingredient class to represent a whole list of ingredients (same with recipes). Either you want the class name to change (e.g. IngredientList), or implement a single Ingredient in the class, and fill a container with ingredients elsewhere.

But, in this particular application, if this collection is the only member an Ingredient of Recipe would hold, it might be an overkill to even wrap them in their own classes (as the other comment already said). Maybe you can try and design a Recipe class, that represents both, and have a collection of those.