Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Greg King
4,073 PointsHaving trouble with method signatures
I can't figure out how to assign the method to this. I put drive(1) thinking that enough parameters were defined but apparently not. Can anyone help me understand how this is done? I feel this particular video lacked something to show me the translation between the 2 scenarios.
Thanks a bunch!
public class GoKart {
public static final int MAX_BARS = 8;
private String mColor;
private int mBarsCount;
public GoKart(String color) {
mColor = color;
mBarsCount = 0;
}
public String getColor() {
return mColor;
}
public void drive(int laps) {
// Other driving code omitted for clarity purposes
mBarsCount -= laps;
drive(1);
}
public void charge() {
while (!isFullyCharged()) {
mBarsCount++;
}
}
public boolean isBatteryEmpty() {
return mBarsCount == 0;
}
public boolean isFullyCharged() {
return mBarsCount == MAX_BARS;
}
}
1 Answer

Ken Alger
Treehouse TeacherGreg;
I wrote a rather long winded explanation on this topic here. Take a look and if you are still stuck, please post back. This is an important topic and having a good understanding of it is important going forward.
Happy coding,
Ken
Greg King
4,073 PointsGreg King
4,073 PointsYes, indeed, Ken...thank you. This helps significantly but I think I need to read a little more on methods and classes before moving to the next step because I don't feel I totally grasp it. Thank you for the quick response. Also, should I be asking these questions differently?
Thanks, Greg
Ken Alger
Treehouse TeacherKen Alger
Treehouse TeacherGreg;
I think you are right on track for the types of and way in which you are asking questions. It is great that you are doing so early on to make sure you have a solid foundation of knowledge.
Happy coding,
Ken