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

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,533 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.