How to make a method to add or not in a List

Hello, everyone, I am starting my studies in java, and I came across a problem that in the case would be: how to make a test not fail to add a pizza without the ingredients list CarrinhoDeCompras. And what class I would have by this method?

Note: I've been told that's pretty bad encapsulated, but not yet learned this concept well, then leave to apply after I well understand this issue.

Please mark all your fields private (as Knute has already told you) and don't mark any of them static. You will doubtless want ingredients for one pizza, rather than a total of ingredients for the whole shop.
Why have you got contaPizza at all? Why have you marked it static?

permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad: