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 trialAaron Drew
713 PointsHow to solve Drive and Catch Challenge?
The code in Main.java is going to throw an illegalArgumentException when the drive method is called. Catch it and warn user. Where is my code going wrong?
public class Main {
public static void main(String[] args) {
GoKart kart = new GoKart("yellow");
if (kart.isBatteryEmpty()) {
System.out.println("The battery is empty");
}
kart.drive(2);
}
}
Robert Richey
Courses Plus Student 16,352 PointsHi Aaron,
I added markdown to help make the code more readable. If you're curious about how to add markdown like this on your own, checkout this thread on posting code to the forum . Also, there is a link at the bottom called Markdown Cheatsheet that gives a brief overview of how to add markdown to your posts.
Cheers!
1 Answer
Robert Richey
Courses Plus Student 16,352 PointsI copy / pasted your code into the challenge and found that it needed two more closing curly braces at the end. Adding these passed the challenge.
Hope this helps,
Cheers
Aaron Drew
713 PointsThanks alot Robert! God Bless!
Aaron Drew
713 PointsAaron Drew
713 Points