Android Build an Interactive Story App Finishing the User Interface Using a Model in the Presenter

this fixed me help

The LandingActivity interacts with the Spaceship model object we created. Start by setting spaceship to a new Spaceship object in the onCreate() method. Use the custom constructor that takes a String parameter, and pass in "FIREFLY" as the parameter.
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class LandingActivity extends Activity {

    public Button mThrustButton;
    public TextView mTypeLabel;
    public EditText mPassengersField;

    public Spaceship mSpaceship;

    public void onCreate(Bundle savedInstanceState) {

        mThrustButton = (Button)findViewById(;
        mTypeLabel = (TextView)findViewById(;
        mPassengersField = (EditText)findViewById(;

        // Add your code here!
        mSpaceship = new Spaceship("FIREFLY");
        mPassengersField.setText(mSpaceship.getNumPassengers() + "");
public class Spaceship {
    private String shipType;
    private int numPassengers = 0;

    public String getShipType() {
      return shipType;

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

    public int getNumPassengers() {
      return numPassengers;

    public void setNumPassengers(int numPassengers) {
      this.numPassengers = numPassengers;

    public Spaceship() {
      shipType = "SHUTTLE";

    public Spaceship(String shipType) {
      this.shipType = shipType;
   public Spaceship(String type) { //<----You have to type a String inside the method
      mType = type;

2 Answers


I think your code is fine - just leave the variable names alone!

So first, reset the challenge back to the beginning and don't amend any of the code that is already there. That puts the variables back.

Then, for the first task, rather than using your line:

mSpaceship = new Spaceship("FIREFLY");

/// use this

spaceship = new Spaceship("FIREFLY");

Next, you need to use the getShipType() method to set the TextView. Your code is close:


// should be 


Lastly you need to change:

mPassengersField.setText(mSpaceship.getNumPassengers() + "");

// should be

passengersField.setText(spaceship.getNumPassengers() + "");

The main issue was you changing the variable names.


Very well explained Steve!

Hi there,

You've changed the names of the member variables to include the old convention of preceding them with an m. Whether you should do this or not is academic. The tests in this challenge are looking for a instance of Spaceship called spaceship. You've not called it that, so the challenge won't pass. You've renamed most of the member variables in both classes - the static tests can't cope with that.

I'd suggest resetting the challenge back to the beginning and starting again while leaving the existing code alone. Your code is mainly correct, apart from there's no method called getType(), it's getShipType.

If you don't know why your code fails the challenge, hit the preview button and you'll see the compiler output which should help.

Good luck!


so can you help me to pass this challenge