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 trialHayden Bohlen
571 PointsCould anyone help me pass this challenge. I am not certain what is wrong with the code.
The error message reads that mBars needs to be set private but when i do the error says that mBars needs to private not entire sure. I would appreciate the help
public class GoKart {
public static final int MAX_BARS = 8;
private String mColor;
public int mBars;
public GoKart(String color) {
mColor = color;
mBars = 0;
}
public String getColor() {
return mColor;
}
}
2 Answers
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 PointsHello Hayden,
You're close on this. I believe they want the variable to be called mBarsCount, just declare that as private when you make it and you already did a good job setting it to 0 in the constructor, so that should sort things out.
Let me know if this doesn't help.
Jess Sanders
12,086 PointsLook at this code for your example to follow. Connecting the challenge questions to the material covered in the lesson may be a good strategy throughout the course:
public class PezDispenser {
public static final int MAX_PEZ = 12;
private String mCharacterName;
private int mPezCount;
public PezDispenser(String characterName) {
mCharacterName = characterName;
mPezCount = 0;
}
public void load() {
mPezCount = MAX_PEZ;
}
public String getCharacterName() {
return mCharacterName;
}
}
- Instead of MAX_PEZ, you are creating MAX_BARS
- Instead of mPezCount, you are creating mBarsCount
- Instead of a load method, you are creating a charge method
Robert Richey
Courses Plus Student 16,352 PointsRobert Richey
Courses Plus Student 16,352 PointsHi Rob,
Just wanted to say it's great to see you get a mod tag :)
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 PointsRob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 PointsHey Robert!
Thanks, pretty excited that it happened, good to see a familar face (avatar?) on the forums this later in the evening.