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

There is a compiler error. Please click on preview to view your syntax errors! Restart

i don't whats wrong with my code

LandingActivity.java
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;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_landing);

        mThrustButton = (Button)findViewById(R.id.thrustButton);
        mTypeLabel = (TextView)findViewById(R.id.typeTextView);
        mPassengersField = (EditText)findViewById(R.id.passengersEditText);

        // Add your code here!
        mSpaceship = new Spaceship("FIREFLY");
        mTypeLabel.setText(mSpaceship.getType());
        mPassengersField.setText(mSpaceship.getNumPassengers() + "");
    }
Spaceship.java
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;
   }
}

1 Answer

Seth Kroger
Seth Kroger
56,382 Points

There are a couple of things causing the errors. First, the getter in the task is named getShipType(), not getType(). Second, I see you changed all the variables over to the m-prefix notation. That's perfectly fine for your own work, but the challenge tester will expect them to retain their original names.