Objects that protect themselvesbeginner
If a caller can reach the data, every rule you wrote about it is optional — and a getter that hands back the real array is the most common way that happens.
A basket whose rules live in every caller. Move them inside.
No caller outside the class can put the basket into a state its methods would refuse.
Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.
If a caller can reach the data, every rule you wrote about it is optional — and a getter that hands back the real array is the most common way that happens.