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

Sarvesh Tandon
Sarvesh Tandon
1,142 Points

Why is there an error saying that the compiler cannot recognize the symbol typeLabel?

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

        thrustButton = (Button)findViewById(R.id.thrustButton);
        typeLabel = (TextView)findViewById(R.id.typeTextView);
        passengersField = (EditText)findViewById(R.id.passengersEditText);

        // Add your code here!
      spaceship= new Spaceship("FIREFLY");
      typeLabel.setText(spaceship.getShipType());
    }
}```

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

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

        thrustButton = (Button)findViewById(R.id.thrustButton);
        typeLabel = (TextView)findViewById(R.id.typeTextView);
        passengersField = (EditText)findViewById(R.id.passengersEditText);

        // Add your code here!
      spaceship= new Spaceship("FIREFLY");
      typeLabel.setText(spaceship.getShipType());
    }
}
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;
    }
}

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Sarvesh;

I was able to get the code you provided above to pass just fine. Perhaps try it again?

Post back if you're still stuck.

Happy coding,
Ken

Sarvesh Tandon
Sarvesh Tandon
1,142 Points

Thanks! It somehow worked this time. Sorry for bothering you!