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 (Retired) Harnessing the Power of Objects Methods and Constants

:PezDispenser pd = new PezDispenser("Yoda"); is not a valid command

I went through trying to see if I had a spelling error, but couldn't see any. Why am I getting this error message repl?

public class PezDispenser{
  public static final int MAX_PEZ = 12;
  private String mCharacterName;
  private int mPezCount;
  public PezDispenser(String characterName) {
   mCharacterName = characterName; 
  }

  public String getCharacterName() {
    return mCharacterName;
    mPezCount = 0;
  }

  public boolean isEmpty() {
   return PezCount == 0;
  } 
  public void load() {
    mPezCount = MAX_PEZ;
  }

  public String getCharacterName() {
    return mCharacterName;
  }
}

1 Answer

Hi Viola,

Don't know if you're still working on this. But I think I have the answer you wrote:

public String getCharacterName() { return mCharacterName; mPezCount = 0;

But I think it is ment to be:

public String getCharacterName() { return mmPezCount = 0;

Hope this helps.