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 The Model-View-Presenter Pattern Creating a Data Model

i need help been stuck for two days

the task requires me to set a setter for the code below

Spaceship.java
public class Spaceship {
  public String mType;
  public String getType() {
    return mType; }
 public void setType(String type) {
    mType = type; 
}

3 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

HI Geraldine,

In terms of Syntax, the only error is a missing closing curly brace for the Class. Once the Class is closed, the code is 100% correct in syntax.

However, I'm guessing you copy / pasted from somewhere, because none of the variables are named correctly. The instructions for the tasks are very specific and very strict. The above code does not even pass the second task. If you are on task #4 then you changed too many things and are no longer matching the instructions.

Task #2 wants a variable named shipType, but you have mType ... Incidentally, the 'm' naming convention is no longer the accepted convention in Android development, so member variables should not be prefixed with an 'm'

Task #3 wants a getter, which you have named getType, which is incorrect (as is the return value) once you correct the variable name from Task #2... Same with the setter for Task #4.

Overall, you have all the syntax correct once you add the Class's closing curly brace. So, I suggest just restarting the challenge and follow the variable naming as stated in the instructions.

Keep Coding! :) :dizzy:

Had changed almost everything on the code since i kept getting the same error.

Thank you

public class Spaceship{

public String shipType ;

public String getShipType(){ return shipType; }

public void setShipType( String shipType){ this.shipType = shipType; } }