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

alex gwartney
alex gwartney
8,849 Points

The quiz is saying that my set method is wrong and i cant seem to see why its not working?

The compiler is also saying i am missing a return statement which also makes no sense since its a setter method.

Spaceship.java
public class Spaceship{

  public String mType;

  public String getType(){

      return mType;
  }

  public setType(String mType){
      this.mType = mType;

  }



}

3 Answers

Hello,

In

  public setType(String mType){
      this.mType = mType;

  }

the function itself is missing whether you want to return something(and if so, what type) otherwise it needs to be void. For example

public void someMethod(int someInt) {
// Does some stuff but no return statement
}

Please let us know if this clears things up for yourself or if you need more assistance and we can help further.

alex gwartney
alex gwartney
8,849 Points

ah ok completely looked over that fact thanks for help.

You're welcome. Have fun with Android development.