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

Aboudi ABU SAMRA
Aboudi ABU SAMRA
1,000 Points

NEED DESPERATE HELP

This error code keeps occurring, I think the code is right.

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;
    } 
    else{
    return false;
    }
}

3 Answers

Steven Parker
Steven Parker
231,210 Points

Aboudi ABU SAMRA, If you're going to choose yourself as "best answer" you should at least provide an actual answer for the benefit of other readers. Explain exactly what needed to be changed in the above code to resolve the issue, particularly since it should be something else than the advice already offered by other students .

Steven Parker
Steven Parker
231,210 Points

Aboudi ABU SAMRA still working on updating your answer?

I am most curious to see how your final solution differs from what was given in the other answers.

Steven Parker
Steven Parker
231,210 Points

It looks like you're missing a close brace :point_right: } :point_left:.

You have closing braces for the if and the else, but not for the isBatteryEmpty method itself.

Aboudi ABU SAMRA
Aboudi ABU SAMRA
1,000 Points

Didn't work. error code:

Bummer! java.lang.IllegalArgumentException: ParseException: com.github.javaparser.ParseException: Encountered " ";" "; "" at line 19, column 22. Was expecting one of: "instanceof" ... ")" ... "=" ... "<" ... "?" ... "==" ... "<=" ... ">=" ... "!=" ... "||" ... "&&" ... "+" ... "-" ... "" ... "/" ... "&" ... "|" ... "^" ... "%" ... "+=" ... "-=" ... "=" ... "/=" ... "&=" ... "|=" ... "^=" ... "%=" ... "<<=" ... ">>=" ... ">>>=" ... "->" ... "::" ... ">" ... (Look around Inspector.java line 73)

Chad Sager
Chad Sager
7,598 Points

its just a } at the end of your classGokart. class GoKart { public static final int MAX_BARS = 8; private String color; private int barCount; } gotta close your classes dog

Aboudi ABU SAMRA
Aboudi ABU SAMRA
1,000 Points

Didn't work

error code: Bummer! java.lang.IllegalArgumentException: ParseException: com.github.javaparser.ParseException: Encountered " ";" "; "" at line 19, column 22. Was expecting one of: "instanceof" ... ")" ... "=" ... "<" ... "?" ... "==" ... "<=" ... ">=" ... "!=" ... "||" ... "&&" ... "+" ... "-" ... "" ... "/" ... "&" ... "|" ... "^" ... "%" ... "+=" ... "-=" ... "=" ... "/=" ... "&=" ... "|=" ... "^=" ... "%=" ... "<<=" ... ">>=" ... ">>>=" ... "->" ... "::" ... ">" ... (Look around Inspector.java line 73)