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 trialalbert gregorio
Courses Plus Student 866 PointsHi there, sorry for asking, but can you help me out here ?... i cant figure out of what is wrong here in my code.thanks
The error says that i must make sure i put the mType to the constructor
public class Spaceship {
public String mType;
public Spaceship() {
mType = " SHUTTLE";
}
public String getType() {
return mType;
}
public void setType(String type) {
mType = type;
}
}
1 Answer
Mahmoud Yousif
5,053 PointsWhat this challenge is asking you to do is to create a new constructor that takes a string parameter. When the object is constructed it will take a the string and place it in the mType member variable.
//This is the constructor they are asking for
public Spaceship(String type) {
mType = type;
}
//So when this object is constructed in the future, it will set the type, based on what is passed in creation
//example:
Spaceship spaceship = new Spaceship("Super type");