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 trialAhmed Sadat
Java Web Development Techdegree Student 643 PointsHi guys in this task he said you don't pass task 1 but i actually i pass it
The task need to make two methods " isEmpty() " to check the barCount is equal to 0 or not and i did with no problem and the second method "isFully()" to check the barCount is equal to MAX_BARS and also i did it but there is error "Yo don't pass task 1" !!
class GoKart {
public static final int MAX_BARS = 8;
private String color;
private int barCount;
public boolean isFullyCharged(){
retrun barCount != MAX_BARS ;
}
public GoKart(String color) {
this.color = color;
}
public String getColor() {
return color;
}
public void charge() {
barCount = MAX_BARS;
}
public boolean isBatteryEmpty(){
if( barCount == 0)
return true ;
else
return false ;
}
}
3 Answers
Patrik Horváth
11,110 Pointsi dont see in your code method "isEmpty()" looks like you called it "isBatteryEmpty" always use same names as they asked also in real life ! never use other method names never just never because you will get UML diagram and you have to have same code like on UML diagram
Ahmed Sadat
Java Web Development Techdegree Student 643 PointsThanks Patrik it is silly mistake
Patrik Horváth
11,110 Pointsdont use TreeHouse code editor use normal IDE it clearly tell you : Syntax error on line 10 for example or when you start type it will show you suggestions for type
for Java try : IntelliJ its best for java + hibernate + sprint + .... in my opinion :)
Ahmed Sadat
Java Web Development Techdegree Student 643 Pointsokay Patrik thanks
Ahmed Sadat
Java Web Development Techdegree Student 643 PointsAhmed Sadat
Java Web Development Techdegree Student 643 Pointsok sorry i mean ( isBatteryEmpty() ) but the implementation of it is true why i get error ?!
Patrik Horváth
11,110 PointsPatrik Horváth
11,110 Pointsbecause "retrun " is not valid you have to use "return"