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 trialWilliam Smith
3,840 Pointsnow create a method named charge that sets the new barCount field to the maximum amount of bars available for each GoKar
i keeps telling me to go back to task 1.
public class GoKart {
private String mColor;
public static final int MAX_ENERGY_BARS = 8;
private int mBarsCount;
public GoKart(String color) {
mColor = color;
mBarsCount = 0;
}
public String getColor() {
return mColor;
}
public void charge(){
mBarsCount = MAX_ENERGY_BARS;
}
}
1 Answer
Steve Hunter
57,712 PointsHi William,
The first task is Create a new private field named barCount. You've called yours mBarsCount
. That's what's causing the issue, I think.
The tests are looking for a member variable called barCount
to be set to the value of MAX_BARS
, not MAX_ENERGY_BARS
. So, you'll need to change the name of the constant back again too.
I hope that helps,
Steve.
macmondiaz
1,415 Pointsmacmondiaz
1,415 PointsHello Steve,
I'm having a problem on mine. It tells me to go to task 1 as well :
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsHi there,
That's because your
charge()
method is returningvoid
andString
. It should just bevoid
:Steve.