Android Build an Interactive Story App The Model-View-Presenter Pattern Adding a Custom Constructor

Caleb Seeling
Caleb Seeling
1,189 Points

Cant end the Task!

I am trying to solve the Task. I tried almost everything I knew and learned in the video but cant solve the Task. Please Help!

Spaceship.java
public class Spaceship {
    public String shipType;

  public void shipType(String shipType) {
    this.shipType = "SHUTTLE";
  }

    public String getShipType() {
      return shipType;
    }

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

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 144,350 Points

Hey Caleb,

You are on the right track, but there are a couple of things here.

First, the instructions explicitly state to create a constructor "with no parameters", but you have added a parameter.

Second, the constructor does not return anything, so you shouldn't have the void keyword as part of it.

Now, once those are corrected, it's just a matter of assigning the value. This is done as you would with any normal variable in Java.

Below is the correct constructor for your review with the notes above. Also, it good to remember that Challenge instructions are very specific and will always need to be followed exactly... or you will get the Bummer.

public Spaceship() {
  shipType = "SHUTTLE";
}

Keep Coding! :) :dizzy: