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 trialThomas Duff
632 PointsGetting the GoKart color
I'm not sure how I'm supposed to fix this issue I've been having with this code challenge.
Basically, I need to add a public method (a getter) that will get the color of the GoKart. However, I'm not really sure how to do it & I've already tried a couple of methods. Here's what I've coded & tried:
It's probably just that I'm misunderstanding this step, but I'd really appreciate some help.
public class GoKart {
public String mColor = "red";
public String = System.out.printf("The GoKart color is %s\n",
}
1 Answer
Ruud Claassen
9,359 PointsThe goal of the challenge here is not to output the value of mColor (as you are doing with System.out.printf), but to return it.
If you take a look at the video prior to the challenge (https://teamtreehouse.com/library/java-objects/meet-objects/privacy-and-methods) at around 1:32, you will see how Craig Dennis creates a getter for the mCharacterName.
Thomas Duff
632 PointsThomas Duff
632 PointsThank you for explaining.
Just didn't understand the challenge, haha. Finished it now.