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 trialVolodymyr Rozdolsky
3,732 Pointspd.fill(); pd.isEmpty(); ==>true?
Can't understand what am I doing wrong min 5:20 I been fallowing along and I get ==>trudgen's instead of ==>false
class PezDispenser { public static final int MAX_PEZ = 12; final private String characterName; private int pezCount;
public PezDispenser(String characterName) { this.characterName = characterName; int pezCount = 0; }
public void fill() { pezCount = MAX_PEZ; }
public boolean isEmpty () { return pezCount == 0;
}
public String getCharacterName(){ return characterName; } }
2 Answers
Trent Christofferson
18,846 Pointsafter
this.characterName = characterName;
you did
int pezCount = 0;
which is creating a new variable. do this:
pezCount = 0;
Volodymyr Rozdolsky
3,732 PointsThank you for answering. Yes now its working.
Trent Christofferson
18,846 PointsGlad I could help!
Amrit Pandey
17,595 PointsAmrit Pandey
17,595 Pointstry to enclose your code between ``` (these three backtics, you'll find them left of 1 key) and then post it.