Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Jack McClelland](https://uploads.teamtreehouse.com/production/profile-photos/10699473/micro_IMG_5684.jpg)
Jack McClelland
1,356 Points!isEmpty() was used to determine if dispenser was full - not being empty is not the same thing as being full though?
This logic doesn't make sense to me: "if the container isn't empty, then print out 'dispenser is full'" Because the dispenser could have 3 pez in it for example, which is not empty but also not full.
Also why print this out right after filling the dispenser, when it's clear that the dispenser is full?
3 Answers
![Sean M](https://secure.gravatar.com/avatar/950cda97fccb24717ba01c39ee8ac75f?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Sean M
7,344 Pointsif you're referring to this code below:
public boolean dispense() {
boolean wasDispensed = false;
if (!isEmpty()) {
pezCount--;
wasDispensed = true;
}
return wasDispensed;
}
The !isEmpty is checking if it's not empty, not if it's full. If it's not empty, it will decrement the pezCount.
![Anastasios Poursaitedes](https://uploads.teamtreehouse.com/production/profile-photos/9139862/micro_DSC_0465.jpg)
Anastasios Poursaitedes
10,491 PointsHey Jack, before we check if the dispenser is not empty we fill the dispenser with the fill() method. I think Graig just illustrated that if we do the check again we will see that the dispenser has been filled and it's no longer empty.
![Luis Marsano](https://secure.gravatar.com/avatar/a0c23ecad9485497d2bc99b81dc7fb79?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Luis Marsano
21,425 PointsRight, it's a domain logic error to infer from the condition alone that the dispenser is full. If we're including previous statements and the condition to justify the assertion, then the condition serves no purpose, since the assertion follows from previous statements alone. You could call it a poor example.