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 trialSara Brothers
7,341 PointsJava Objects Challenge
I am not sure what the code should be. Please help!
public class GoKart {
public static final int MAX_ENERGY_BARS = 8;
private String mColor;
private int mBarsCount;
public GoKart(String color) {
mColor = color;
mBarsCount = 0;
}
public String getColor() {
return mColor;
}
public void charge() {
mBarsCount = MAX_ENERGY_BARS;
}
public boolean isBatteryEmpty() {
return mBarsCount == 0;
}
public boolean isFullyCharged() {
boolean isFullyCharge = false;
if (!mBarsCount()) {
mBarsCount--;
mBarsCount = true;
}
}
}
1 Answer
Brian Fallon
4,733 PointsI am can't say to be sure, but it looks as though you have edited the isFullyCharged() method. You actually want to edit the charge() method and utilize the isFullyCharged() method in your while statement by saying :
while (!isFullyCharged()) {
}
I don't want to give you any more hints than that so you can still work through the solution, but you will need an if statement inside of your loop.
Brian Fallon
4,733 PointsBrian Fallon
4,733 PointsSorry, I meant for this to be an answer, it will be below.