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 trialpinar
2,329 PointsTry Again! problem
I keep getting "Try again" error about my second task. it doesn't give me a specific error message. When I preview the code it doesn't show anything. Here is my first task code public class GoKart { private String mColor; public GoKart(String color) { mColor = color; } public String getColor() { return mColor; } } Thank you
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
GoKart kart = new GoKart("blue");
System.out.printf("let's dye a Gokart %s\n.",kart.getColor());
}
}
4 Answers
Michael Hess
24,512 PointsHi Pinar,
I was able to pass both tasks using your code. I had to comment out the printf statement to pass task 1 after copy & pasting.
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
GoKart kart = new GoKart("blue");
// uncomment printf after task1 is passed
// System.out.printf("let's dye a Gokart %s\n.",kart.getColor());
}
}
If you have any questions I will be happy to answer them.
pinar
2,329 PointsDear Michael, changing my answer for part 1 worked! Thank you so much for helping me! A little help really makes a big difference :) And thank you for your support - I'm very new at this, so it's really nice to hear encouragement.
Michael Hess
24,512 PointsNo problem -- I'm glad that I could help!
pinar
2,329 PointsHi Michael, Thank you very much for helping. However, I took the \n out of my code and İ still get the error. İ even copy-pasted your code in, and it doesn't pass. Hmm... this is very strange.
ISAIAH S
1,409 PointsYou were very close:
// For the first task:
public class Example {
public static void main(String[] args) {
GoKart goKart = new GoKart("blue");
System.out.println("We are going to create a GoKart");
// And the second:
System.out.printf("The color of the GoKart is %s", goKart.getColor());
}
}
So I guess you didn't need the 'System.out.printf("let's dye a Gokart %s\n.",kart.getColor());
' until the second task.
Hope it helps!
Michael Hess
24,512 PointsWhat Pinar wrote is corrrect -- it's just the way the challenge was designed. Pinar's code is correct. I copy & pasted Pinar's code to check it.
Nothing about the code needs to be changed.
Michael Hess
24,512 PointsMichael Hess
24,512 PointsIf you copy and paste you need to make sure the printf (task 2) is commented out -- or you'll get an unspecified error on task 1. Uncomment the printf line after task 1 is completed.
The \n works though. But, if you paste the whole code block -- you'll get an unspecified error on task 1 of the challenge.
The code is correct, but the way the challenge was designed is causing the error -- if that makes any sense.