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 Stoelinga
746 Points[SOLVED] Stuck with creating a new GoKart object with parameter.
I can't seem to figure this out. I think this code should be right, but something is obviously wrong or I would pass the test :)
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
GoKart redKart = new GoKart ("red");
System.out.printf("The GoKart is %s", redKart.getColor() );
}
}
Shivam Patel
860 PointsMark, I am struggling with the same challenge - I am getting a try again message - my code looks the same as yours but feel that the task before hasn't transferred through. What error message were you seeing?
Mark Stoelinga
746 PointsHey Shivam,
That was the weird thing, there were no error messages in the "preview" window, so the code should work(I think). maybe there is some peculiarity in the check treehouse with their "right" code comparison. I also played around with the "redKart" name, and changed it into "gokart" all lower case letters. Hope this helps! Good luck :)
Shivam Patel
860 PointsThanks for your reply Mark - managed to complete the Challenge.
Mark Stoelinga
746 PointsAwesome, Congrats!
Ken Alger
Treehouse TeacherEdited title to [SOLVED]
Gentlemen;
In terms of what you name your cart, it really shouldn't matter as long as you stay away from Java defined words. So naming your cart String, or int for example won't work. However, using descriptive names like redKart, reallySuperFastKart, markKart, shivamKart are all acceptable. The important thing is the syntax
Think of creating objects in Java. For this example what are we creating, a GoKart object named whatever. Let's call it blueKart, so we need to tell Java "Hey we are creating a new GoKart object, going to name it blueKart and since you need to know the color, we're going to give it a value of blue." In Java, as you know from the course and challenge, that looks like:
GoKart blueKart = new GoKart("blue");
Great job on making it through this one and figuring out the syntax issues, they can keep even the most experienced developers occupied for long periods of time.
Happy coding and welcome to Treehouse!
Ken
3 Answers
Abdul Bari Ahmadzai
477 PointsHi, I have the same issue, I tried the same code but i get a try again message while there is no error shown.
Ken Alger
Treehouse TeacherAbdul;
Welcome to Treehouse!
Will you post the code you are using on a new forum post? Let's see if we can't get this resolved for you.
Ken
Dean Onizuka
4,753 PointsSystem.out.printf("The GoKart is %s", redKart.getColor() );
that line by itself in the code above should not work. yet it passes the exercise? wouldnt you always get an error because getColor has not be defined anywhere. In the previous examples in this lesson we had a seperate file where the getCharacterName was defined with the mCharacterName and all that... yet here we are doing something completely different.
i think thats where lots of the confusion comes from. or am i missing something here?
Abdul Bari Ahmadzai
477 PointsHi Dean,
Thank you for clarification. Indeed, this is what confuses me, but still i can't pass the exercise with this code. There is no description for the error i receive. It says "Bummer Try Again".
I don't know how to move forward from this exercise.
Mark Stoelinga
746 PointsMark Stoelinga
746 PointsFixed it after deleting the space after "new GoKart (". Works! Sorry to bother you guys :)