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 trialEric Greer
4,997 PointsReturning Boolean but not working?
I am returning the boolean result of the mBarsCount == 0 evaluator but the test keeps asking me to return a Boolean...
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 Boolean isBatteryEmpty(){
return mBarsCount == 0;
}
public void charge() {
mBarsCount = MAX_BARS;
}
}
2 Answers
Lucas Smith
11,616 PointsI think that the problem may be one of case, with Boolean and boolean being different.
Also, sorry about posting this twice. I'm quite new to the forums here, and didn't see the answer section hidden at the bottom of the page.
Ken Alger
Treehouse TeacherEric;
In Java, Boolean returns true or false, not 0 or 1, which are of type int.
Ken
Eric Greer
4,997 PointsmBarscount is followed by two equals signs, making it an evaluator. The entire section mBarsCount == 0 should be resolved into a Boolean true or false then returned in the isBatteryEmpty method.
Ken Alger
Treehouse TeacherDoh! You're correct. Blurring eyes tonight, sorry.
Eric Greer
4,997 PointsI appreciate you taking the time to read my question!
Eric Greer
4,997 PointsEric Greer
4,997 PointsYou were right! The uppercase Boolean is valid java but apparently not in the team tree house editor (for at least this challenge). When i lowercased the boolean on the method, it worked perfectly. Thanks!