Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build an Interactive Story App The Model-View-Presenter Pattern Creating a Data Model

Dominic Sayers
Dominic Sayers
4,279 Points

Finally, add the setter method What am I doing wrong?

It also says there the previous one is invalid but I didn't change anything in the previous answer

Spaceship.java
public class Spaceship{
    public String shipType; 

  public String getType(){
     return shipType; 
  }

  public void setType(String type){
     shipType = type; 
  }
}

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're doing great, but it has a bit of a problem with your naming conventions here. It wants getShipType and setShipType. It is a spaceship, after all. It could also have properties of weaponType, engineType, crewType, missionType etc. So getType and setType might not be as descriptive as you think it is.

Hope this helps! :sparkles:

Dominic Sayers
Dominic Sayers
4,279 Points

That worked thank you! just curious why getShipType and not getshipType after-all its returning shipType and not Shiptype?

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Because that's standard for camel-case. Every individual word is capitalized. That being said, if you had a compound word, you wouldn't need to break that up. For example you would write: getBaseball instead of getBaseBall as "baseball" is one word. The exception to this is when we make classes which are what we call upper camel-case. They begin with a capital letter. Hope this helps! :sparkles:

Yes! As Jennifer Nordell Said your code should look like this:

public class Spaceship{
    public String shipType; 

  public String getShipType(){
     return shipType; 
  }

  public void setShipType(String type){
     shipType = type; 
  }
}
Dominic Sayers
Dominic Sayers
4,279 Points

That makes sense Thank you again!