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 trialBill Rebello
467 PointsOops! It look like Task 1 is not longer Passing Help??
Why is this not working? Spending too much time trying to figure this out.
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
11,246 PointsYou didn't close if statement in isBatteryEmpty() method.
Bill Rebello
467 PointsThank you very much but not seeing that if statement in isBatteryEmpty() method is open??
Vladut Astalos
11,246 PointsYes 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
467 PointsYes I finally see it! Thank you very much! I'm still have issues with when to enter { or }
Vladut Astalos
11,246 PointsI'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.