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 144,350 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; } }