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 trialnick ching
6,528 PointsPlease make your field public
i have made mBattery field, however when i check my work, i get make mBattery a public field. I am certain that my code is correct, please help!
public class GoKart {
public static final int MAX_BATTERY = 8;
private String mColor;
private int mBattery;
public GoKart(String color) {
mColor = color;
mBattery = 0;
}
public void load () {
mBattery = MAX_BATTERY;
}
public String getColor() {
return mColor;
}
}
2 Answers
Kourosh Raeen
23,733 PointsThe problem is the name of the member variable not the private access modifier. The variable name is supposed to be mBarsCount:
public class GoKart {
public static final int MAX_BATTERY = 8;
private String mColor;
private int mBarsCount;
public GoKart(String color) {
mColor = color;
mBarsCount = 0;
}
public String getColor() {
return mColor;
}
}
Jennifer Nordell
Treehouse TeacherYour code is actually fine. The problem is in the details of the challenge. It explicitly asks for a variable named mBarsCount. You've used mBattery. If i change out your mBattery for the correct variable name ... it passes. Here's the code:
public class GoKart {
private String mColor;
public static final int MAX_BATTERY = 8;
private int mBarsCount;
public GoKart(String color) {
mColor = color;
mBarsCount = 0;
}
public String getColor() {
return mColor;
}
}