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

Android Build an Interactive Story App (Retired) The Model-View-Controller Pattern Creating a Data Model

Now add a String member variable named mType. Make it public.

public class spaceship {

public String mType;

}

Spaceship.java
public class spaceship {

    public String mType;
}

public class Spaceship { public String mType;

public String getType() { return mType;}

public void setType(String type) {} this.mType = mType;} }

3 Answers

Damien Watson
Damien Watson
27,419 Points

The 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;
}

i dnt kno wats wrong here public class Spaceship { public String mType;

public String getType() { return mType;}

public void setType(String type) {} this.mType = mType;} }

i 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
Damien Watson
27,419 Points

The 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;
  }