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 trialChris Perrett
2,958 PointsI don't know where to begin, except with the question. Please, if you can, answer and explain.
.
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
GoKart blah = new color();
}
}
1 Answer
Chase Marchione
155,055 PointsHi Chris,
Since you are creating a new GoKart object, your instantiation statement (the statement in which you create a new GoKart object) will specify 'new GoKart'.
GoKart exampleKart = new GoKart("orange");
The left side of that statement specifies that we are going to assign something to an object of type GoKart. In my example, I let the compiler know that the name of that GoKart object is 'exampleKart'. On the right side of the statement, we use the 'new' keyword so that the compiler knows that we are creating a new object. After the 'new' keyword, I specify that this newly created object is to be of type GoKart. In parentheses, I pass in a value for the GoKart's color.
For tasks 1 and 2:
public class Example {
public static void main(String[] args) {
System.out.println("We are going to create a GoKart");
GoKart exampleKart = new GoKart("orange");
System.out.printf(exampleKart.getColor()); // GoKart objects have a getColor method.
}
}
Hope this helps!
Chris Perrett
2,958 PointsThanks for the response, I've been really struggling. I really don't want to quit though so I am thinking of going back to the last section (where you created a madlib) and try to learn how to create madlibs on my own. I see you have a lot of coding experience, how do you keep up with this stuff? Do you apply the knowledge a lot before you move on? I'm hoping it is more about application of knowledge rather than talent, otherwise I'd better look elsewhere for a skill in something.
Chris Perrett
2,958 PointsChris Perrett
2,958 PointsTHE QUESTION IS "Please create a new GoKart object. As you know it takes a single parameter, color."