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 trialYoussef Bourahla
442 PointsPLS HELP ME I HAVE BEEN ON THIS ONE ALMOST THE WHOLE DAY , it tells me that task one is no longer passing
here is my code when I create the isFullyCharged method , the isBatteryEmpty stops working
class GoKart {
public static final int MAX_BARS = 8;
private String color;
private int barCount;
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 (){
barCounter==8;
}
}
2 Answers
Justin Horner
Treehouse Guest TeacherHello Youssef,
The challenge wants you to return a boolean value from the isFullyCharged method. The best way to accomplish this is to compare the current bar count with the MAX_BARS final static variable.
You're currently not returning a value from the isFullyCharged method, so you'll want to use the return key word. Also, you're using a variable called barCounter, but the variable you should use is barCount.
public boolean isFullyCharged () {
return barCount == MAX_BARS;
}
I hope this helps.
Happy Coding :)
Youssef Bourahla
442 PointsxD thanks now thinking about it , what a stupid mistake