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

Java Objects Challenge

I am not sure what the code should be. Please help!

GoKart.java
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() {
    boolean isFullyCharge = false;
    if (!mBarsCount()) {
      mBarsCount--;
      mBarsCount = true;
    }


  }

}
Brian Fallon
Brian Fallon
4,733 Points

Sorry, I meant for this to be an answer, it will be below.

1 Answer

Brian Fallon
Brian Fallon
4,733 Points

I am can't say to be sure, but it looks as though you have edited the isFullyCharged() method. You actually want to edit the charge() method and utilize the isFullyCharged() method in your while statement by saying :

while (!isFullyCharged()) {

}

I don't want to give you any more hints than that so you can still work through the solution, but you will need an if statement inside of your loop.