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 trial
Jeffery Briggette
2,376 PointsStuck on Challenge Task 2 on the Custom Constructors code challenge. Everything I try doesn't work:
I've tried the following;
public Spaceship(String type){ mType = type; }
Not sure what I'm missing any help would be appreciated and yes I'm a newb :(.
5 Answers
Jeremy Faith
Courses Plus Student 56,696 PointsIt does look right. I just did the challenge again and it worked. Here is the code that pass to compare.
public class Spaceship {
public String mType;
public String getType() {
return mType;
}
public void setType(String type) {
mType = type;
}
public Spaceship() {
mType="SHUTTLE";
}
public Spaceship(String type) {
mType = type;
}
}
Jack Middlebrook
19,746 PointsAre you still including the first constructor with no parameters that sets mType to "SHUTTLE"? Your second constructor looks right so make sure you have both constructors included.
Jeffery Briggette
2,376 PointsYep. I have that on there as well. Not sure what I'm missing, this is getting frustrating. Thank you for your help. I'll keep at it, hopefully something will stick.
Jess Walters
3,214 PointsI am getting the same error
Jeffery Briggette
2,376 PointsThanks that worked. I missed something, I re-started the challenge and it worked. I guess I had a typo I wasn't catching. Much appreciated, thanks for everyones contribution.