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 trialKhánh Nguyễn
704 PointsWhy i cant do this quiz
This require me to set a helper method to return true if mBarsCount at Max So in the code i do it
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 boolean isBatteryEmpty(){
return mBarsCount == 0;
}
public boolean isFullyCharger(){
return mBarsCount = MAX_BARS;
}
public String getColor() {
return mColor;
}
public void charge() {
mBarsCount = MAX_BARS;
}
}
Khánh Nguyễn
704 Pointsthks for reminding me . i will do it now
2 Answers
Grigorij Schleifer
10,365 PointsHi Khankh,
you are damn close to victory :)
First task should be absolutely fine:
public boolean isBatteryEmpty(){
return mBarsCount == 0;
// the result of this line is true
//so boolean isBatteryEmpty is true
}
the code for the second task needs a tiny change of the typo :)
public boolean isFullyCharged(){
// you had isFullyCharger
//you need isFullyCharged
return mBarsCount == MAX_BARS;
//here is everething easy and great
}
Shout out if you need more help
Grigorij
Andrew Dummer
6,885 PointsHi Khánh Nguyễn, In return mBarsCount = MAX_BARS, try using == instead of =.
Grigorij Schleifer
10,365 PointsGrigorij Schleifer
10,365 PointsHI Khánh,
could you solve the challenge?
Please mark an answer as best, so the others can see this.
Hope to meet you soon here in the forum !
Grigorij