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 trialValentijn de Haan
527 Pointsit look like I forgot to add the constructor..what am I missing?
I dont see what I am missing here..can anybody give me a clue?
public class GoKart {
private String mColor = "red";
public String getColor() {
return mColor;
}
}
2 Answers
Christian Stanton
25,404 PointsYou need to add a constructor for the GoKart class that takes a parameter of a string called "color".
public GoKart(String color) {
mColor = color;
}
Afrid Mondal
6,255 PointsConstructor means: you have to define a method exactly as same name as it's class. So, in your case the constructor name is GoKart(String color). A parameter name color to pass. Then assign value of this color parameter to your private string variable. Like this....
public class GoKart {
private String mColor = "red";
public GoKart(String color) {
mColor = color;
}
}
Valentijn de Haan
527 PointsTnx for your quick reply.. Got the assignment before the video somehow.. Got it now..
Valentijn de Haan
527 PointsValentijn de Haan
527 PointsTnx for your quick reply.. Looks like I got an assignment before I saw the video.. Got it now..