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 trialAboudi ABU SAMRA
1,000 PointsNEED DESPERATE HELP
This error code keeps occurring, I think the code is right.
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
Aboudi ABU SAMRA
1,000 PointsFixed it myself.. ;/
Steven Parker
231,210 PointsIt looks like you're missing a close brace } .
You have closing braces for the if and the else, but not for the isBatteryEmpty method itself.
Aboudi ABU SAMRA
1,000 PointsDidn'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
7,598 Pointsits 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
1,000 PointsDidn'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)
Steven Parker
231,210 PointsSteven Parker
231,210 PointsAboudi 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 .
Aboudi ABU SAMRA
1,000 PointsAboudi ABU SAMRA
1,000 PointsOk will do.
Steven Parker
231,210 PointsSteven Parker
231,210 PointsAboudi 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.