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

Java Java Objects Harnessing the Power of Objects Abstraction at Play

Volodymyr Rozdolsky
Volodymyr Rozdolsky
3,732 Points

pd.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; } }

Amrit Pandey
Amrit Pandey
17,595 Points

try to enclose your code between ``` (these three backtics, you'll find them left of 1 key) and then post it.

2 Answers

after

this.characterName = characterName;

you did

int pezCount = 0;

which is creating a new variable. do this:

pezCount = 0;
Volodymyr Rozdolsky
Volodymyr Rozdolsky
3,732 Points

Thank you for answering. Yes now its working.

Glad I could help!