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