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 Helper Methods

method named isFullyCharged

Please Help me I cant find solution

GoKart.java
public class GoKart {
  public static final int MAX_BARS = 8;
  private String mColor;
  private int mBarsCount;

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

  public boolean isFullyCharged(){
    mBarsCount == MAX_BARS;
    return ;
  }

  public void isFullyCharged(){
    mBarsCount == MAX_BARS; 
  }
  public String getColor() {
    return mColor;
  }


}

3 Answers

James Tyranski
James Tyranski
3,957 Points

Sure, first make sure you get rid of:

public void isFullyCharged(){
    mBarsCount == MAX_BARS; 
}

Then, try this for your isFullyCharged method to return the count:

public boolean isFullyCharged(){
    return mBarsCount == MAX_BARS;
  }

Thank You So Much :) Works Gr8

James Tyranski
James Tyranski
3,957 Points

Couple of things I see. First is you have two methods with the same name, one returns a boolean and the other doesn't return anything (void). I believe you are on the part of the exercise where you want to return the boolean, so get rid of the other method which has void.

Then you need to finish your boolean method of isFullyCharged because it's incomplete. Without giving you the full answer, use what you learned from PezDispenser.java in your workspace. See specifically the 'public boolean dispense()' method as a reference, as this will be very much like that.

can you please paste the code here please I dont understand how???

thanks James