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 trialCole Turner
5,872 Pointshow do you add a method
How do I add a method called console? for some reason I get a complier issue that onl points to a right bracket.
public class GoKart {
private String mColor;
public static final int MAX_BATTERY = 8;
private int mBarsCount = 0;
public GoKart(String color) {
mColor = color;
}
public int charge() {
mBarsCount = MAX_BATTERY;
}
public String getColor() {
return mColor;
}
}
1 Answer
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 PointsHey there Cole,
I don't remember this challenge wanting us to import a console, however I could be wrong on that as it's been a bit since I've done it.
However the trouble that your code is telling you is that you told it that your charge method will return an int when you declared it.
A simple fix like changing this to
public void charge()
will allow your code to skate on through just fine.
Thanks, let me know if this helps or not.