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 trialMUZ140584 Heredity Mbundire
4,979 PointsNow add a String member variable named mType. Make it public.
public class spaceship {
public String mType;
}
public class spaceship {
public String mType;
}
3 Answers
Damien Watson
27,419 PointsThe only thing I can see that might not be passing is the capital 'S' on Spaceship. I assume the code you have isn't passing the challenge? Try:
public class Spaceship {
public String mType;
}
MUZ140584 Heredity Mbundire
4,979 Pointsi dnt kno wats wrong here public class Spaceship { public String mType;
public String getType() { return mType;}
public void setType(String type) {} this.mType = mType;} }
MUZ140584 Heredity Mbundire
4,979 Pointsi dnt kno wats wrong here public class Spaceship { public String mType;
public String getType() { return mType;}
public void setType(String type) {} this.mType = mType;} }
Damien Watson
27,419 PointsThe get is working as expected, the setter has a few issues. As soon as you open the definition with '{' you close it again. Also global variables as used dont require the 'this.' the final thing being that you are setting it to itself instead of the new variable.
Try this for your setter method:
public void setType(String type) {
mType = type;
}
MUZ140584 Heredity Mbundire
4,979 PointsMUZ140584 Heredity Mbundire
4,979 Pointspublic class Spaceship { public String mType;
public String getType() { return mType;}
public void setType(String type) {} this.mType = mType;} }