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 trialNina Tanzia
1,755 PointsTask 1 no longer working however, my code seems correct.
My code seems correct but is not running because it says the code from task 1 is no longer working.
class GoKart {
public static final int MAX_BARS = 8;
private String color;
public GoKart(String color) {
this.color = color;
}
public String getColor() {
return color;
}
private int barCount;
public void charge
{
barCount = MAX_BARS;
}
}
1 Answer
andren
28,558 PointsYour code is in fact not correct. When it comes to programming even the tiniest of typos can easily cause your program to crash. You are missing parenthesis in your charge method declaration. If you add them like this:
public void charge()
{
barCount = MAX_BARS;
}
Then you will be able to pass the challenge.
Though it's also worth mentioning that while it's not invalid to do so you usually don't place field variables like barCount
in the middle of the class. By convention all field variables should be placed at the top of the class. Just like the other field variables in the solution are.
Nina Tanzia
1,755 PointsNina Tanzia
1,755 PointsI reviewed my code a few times and somehow did not see that I was missing parenthesis in the charge method declaration.
I also moved barCount to the top of the class as you pointed out. Thank you!!!
andren
28,558 Pointsandren
28,558 PointsI don't blame you for not noticing it. It can be extremely difficult to spot minor typos like that especially in the beginning. But it's something you'll likely improve on as you get more used to writing and seeing correctly formatted code.