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 trialFatimah Ghazal
1,848 Pointshi, can you help me with the incrementing quiz
i reached a point where it says : "Something fishy is going on, please only refactor the charge method. and i don't understand what does it mean.
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() {
while(!isFullyCharged()){
mBarsCount++;
}
return mBarsCount == 0;
}
public boolean isFullyCharged() {
return mBarsCount == MAX_ENERGY_BARS;
}
}
1 Answer
andren
28,558 PointsIt means that you modified something different from what the challenge asked you to. The challenge is to refactor the drive method, you have changed the code in the isBatteryEmpty method instead. Which is not what the task asked you to do.
The while loop you have written is actually completely right, the only problem is that it is in the wrong method, if you cut your while loop out of the isBatteryEmpty method and paste it into the drive method (replacing the line that is currently there) then your code will pass the challenge.
Fatimah Ghazal
1,848 PointsFatimah Ghazal
1,848 PointsThanks alot andren ?