What is the need to set pezCount = 0 when it is not in the scope of the constructor. Also why isn't it initialized in the class itself.
hi, u set it to 0 because we simulating the build process of a pezDispenser, in the start u set that every pezDispenser will have 0 pez in it until we call the fill() method in order to fill the pez.
Anastasios Poursaitedes9,333 Points
Actually we have to initialize the pezCount otherwise we will get an error that it is uninitialized. I'm not sure but I think that initialization on the constructor is better if you want to use some kind of logic (loop, if etc.) on the constructor.