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

michael lee
michael lee
5,177 Points

what am I doing wrong?

it says I'm not setting it in the onCreate ??
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class LandingActivity extends AppCompatActivity {

    public Button thrustButton;
    public TextView typeLabel;
    public EditText passengersField;

    public Spaceship spaceship;

    public void onCreate(Bundle savedInstanceState) {
       Spaceship spaceship = new Spaceship("FIREFLY");

        thrustButton = (Button)findViewById(;
        typeLabel = (TextView)findViewById(;
        passengersField = (EditText)findViewById(;

        // Add your code here!

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;

1 Answer

Hi Michael. The Spaceship spaceship variable has already been declared at the top of the class (above onCreate()). So you do not need to declare it again in onCreate(), but just set that existing variable to a new Spaceship object using the constructor, as you did perfectly:

spaceship = new Spaceship("FIREFLY");

Hope that helps :)