Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects (Retired) Harnessing the Power of Objects Methods and Constants

Kern Tallett
Kern Tallett
10,012 Points

Please make the field Public: I can't see where I have gone wrong. Any help is much appreciated.

I am getting an incorrect with a please make the mBatteryCount public. I thought I had made it accessible yet not changeable. I can't see the error I am making.

GoKart.java
public class GoKart {
  public static final int MAX_BATTERY = 8;
  private String mColor;
  private int mBatteryCount;

  public GoKart(String color) {
    mColor = color;
    mBatteryCount = 0;
  }

  public void load() {
    mBatteryCount = MAX_BATTERY;
  }

  public String getColor() {
    return mColor;
  } 
}

1 Answer

Dan Johnson
Dan Johnson
40,532 Points

The challenge is confused about the names you're using. mBatteryCount should be mBarsCount and the method load should be charge.

The actual logic looks fine though, so that should be all you need to change.

Kern Tallett
Kern Tallett
10,012 Points

Thanks Dan. It worked, I followed what I learned from the pez example too closely and ignored the possibility other areas may need a change.