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 Incrementing

Task difficulties

i tried everything that i thot of, can you please take baby steps on me .Its been days now cant figure this one out

public class GoKart {
  public static final int MAX_ENERGY_BARS = 8;
  private String mColor;
  private int mBarsCount;

  public GoKart(String color) {
    mColor = color;
    mBarsCount = 0;

  public String getColor() {
    return mColor;

  public void charge() {
    mBarsCount = MAX_ENERGY_BARS;

  public boolean isBatteryEmpty() {
    return mBarsCount == 0;

  public boolean isFullyCharged() {
    public void charge;
    return mBarsCount == MAX_ENERGY_BARS;


2 Answers


Have a look at this thread; that may walk you through the problem.

You don't want your charge method inside your isFullyCharged method. Separate those first. The code is all OK - it just needs tidying up a bit.

Start with public boolean isFullyCharged() - that just compares mBarsCount with MAX_ENERGY_BARS and returns true/false depending if they're equal or not.

The charge method should increment mBarsCount while mBarsCount is not equal to MAX_ENERGY_BARS.

You've got all the code there!

Have a read of the post linked above and let me know how you get on.


thanks a lot Steve it worked

No problem!