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 trialRubio Salinas
3,051 PointsChallenge: Great! Now let's create a similar method named isFullyCharged that checks to see if the current bar count is
I am really stuck on this part and I have tried other solutions to this challenge with no success. Any help would be greatly appreciated!
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; }}
}
public boolean isFullyCharged() {
if (barsCount == MAX_BARS); {
return true; }
else { return false; }}
}
1 Answer
Steven Parker
231,269 PointsYou're close, but I see 3 issues:
- there's a stray closing brace on line 22 between the two new methods
- there's a stray semicolon on line 24 between the conditional expression and the open brace
- also on line 24 there is "barsCount" (with an extra "s") instead of "barCount"
Tip: structuring your code like the course examples will make it much easier to spot issues like misplaced braces.
Rubio Salinas
3,051 PointsRubio Salinas
3,051 PointsThank you so much Steven! I tried many different variations and tried correcting a bunch of things, but that is what ultimately what worked. Thanks!