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 trialChintan Patel
4,016 PointsWhats the default 1 mean?
i am having hard time understanding what the default 1 is for?
class GoKart {
public static final int MAX_BARS = 8;
private String color;
private int barCount;
private int lapsDriven;
public GoKart(String color) {
this.color = color;
}
public String getColor() {
return color;
}
public void charge() {
barCount = MAX_BARS;
}
public boolean isBatteryEmpty() {
return barCount == 0;
}
public boolean isFullyCharged() {
return MAX_BARS == barCount;
}
public void drive(){
}
public void drive(int numberofLaps) {
lapsDriven++;
barCount--;
numberofLaps+=lapsDriven;
numberofLaps-=barCount;
}
}
1 Answer
Jeff Wilton
16,646 PointsI think they just mean that if you call the drive method and don't pass in any number of laps, then that method will call the other drive method and pass in a default number of laps of 1.
public void drive(){
drive(1);
}
Chintan Patel
4,016 PointsChintan Patel
4,016 PointsThanks for your quick reply:)