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 Harnessing the Power of Objects Computed Properties

Bill Rebello
Bill Rebello
467 Points

Oops! It look like Task 1 is not longer Passing Help??

Why is this not working? Spending too much time trying to figure this out.

GoKart.java
class GoKart {
  public static final int MAX_BARS = 8;
  private String color;
  private int barCount;

  public GoKart(String color) {
    this.color = color;
  }

  public String getColor() {
    return color;
  }

  public void charge() {
    barCount = MAX_BARS;
  }
  public boolean isBatteryEmpty(){
    if (barCount == 0){
      return true;
}
    public boolean isFullyCharged(){
      if(barCount == 8){
        return true;
  }
}
}

3 Answers

Vladut Astalos
Vladut Astalos
11,246 Points

You didn't close if statement in isBatteryEmpty() method.

Bill Rebello
Bill Rebello
467 Points

Thank you very much but not seeing that if statement in isBatteryEmpty() method is open??

Vladut Astalos
Vladut Astalos
11,246 Points

Yes it is, after your condition you open a curly bracket and you didn't close it after return statement. Also in isFullyCharged() method i think you need to replace 8 with your constant 'MAX_BARS' you defined in the beginning.

Bill Rebello
Bill Rebello
467 Points

Yes I finally see it! Thank you very much! I'm still have issues with when to enter { or }

Vladut Astalos
Vladut Astalos
11,246 Points

I'm glad I could help. One way to deal with the brackets is to write both of them and then move your cursor back and write your code between them that way you're sure you never forget to close the brackets.