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 trialMark John
Courses Plus Student 771 Pointsplz i need some help with this java challenge question
Now create a helper method named isFullyCharged. It should return true if the GoKart is at max capacity.......i have tried changing some this int he method but still is not working
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 isFullyCharged() {
return mBarCount = 1;
}
public String getColor() {
return mColor;
}
public void charge() {
mBarsCount = MAX_BARS;
}
}
7 Answers
Jordan Ernst
5,121 Pointshey mark, with your conditions it is super simple and you are more than likely over thinking this. i'll give you the answer so that you can work through this yourself.
public boolean isBatteryEmpty(){
if(mBarsCount== 0){
return true;
}
return false;
}
public boolean isFullyCharged(){
if(mBarsCount == MAX_BARS){
return true;
}
return false;
}
Jordan Ernst
5,121 Pointsso what you are needing to do is check things over and verify whether or not the statement is true. in order for us to do this we need to set some conditions. how do we set a condition >> if(mBarsCount== 0){// than your goKart is empty right?> True. if this is not true than this condition is false and your goKart has fuel.
does this give you enough juice to figure it out? if not i am here to help
Jordan Ernst
5,121 Pointsand remember boolean values only return true or false... 0's and 1's are technically correct but for simplicity sake don't confuse yourself
jrabello
17,917 Pointschange the = operator to == operator and your code will evaluate the expression as a boolean expression
Mark John
Courses Plus Student 771 Pointshey! plz m still having issues with the question i tried using the == operator as jrabello said but it did not still work for me.i als o tried using conditionals but it did not also work i still dont know were i got it wrong.
Mark John
Courses Plus Student 771 Pointsi tried using conditionals lik jordan ernst said but it did not still work. plz i need help. iwant to know were am getting it wrong.
Mark John
Courses Plus Student 771 Pointsthanks mehn!! i just saw my mistake i appreciate the help
Mark John
Courses Plus Student 771 Pointsthanks mehn!! i just saw my mistake i appreciate the help