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 trialEugen Oanta
5,657 PointsI don't know what I am doing wrong
I really don't know what I am supposed to do as the requirements are very non understandable.
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() {
return mBarsCount == MAX_ENERGY_BARS;
}
while (!GoKart.isFullyCharged) {
mBarsCount++;
}
}
2 Answers
Harry James
14,780 PointsHey Eugen!
In this challenge, you want to be writing your code in the charge() method.
So, in this method, we want to create a while loop so that we increment mBarsCount while it is not equal to MAX_ENERGY_BARS. We only want to run this while loop if the battery is not fully charged (Use the helper method!).
This should be all the info you need to get through the challenge now! If you get stuck along the way though, drop a Comment below and I'll help you out :)
Mike D'Aguillo
5,475 PointsLooks like you only posted a class definition and not the description of what it's asking you to do. Though I can see there's a rogue while statement that's just floating in the class. You'll want to wrap that in some sort of function, so that code can be called on command. I'm gonna guess it's the "charge" function, or something similar. Does that make any sense? If not, please post the instructions for the problem you're working on.