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 trialDominic Sayers
4,279 PointsFinally, 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
public class Spaceship{
public String shipType;
public String getType(){
return shipType;
}
public void setType(String type){
shipType = type;
}
}
2 Answers
Jennifer Nordell
Treehouse TeacherHi 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!
Dominic Sayers
4,279 PointsThat makes sense Thank you again!
Dominic Sayers
4,279 PointsDominic Sayers
4,279 PointsThat worked thank you! just curious why getShipType and not getshipType after-all its returning shipType and not Shiptype?
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherBecause 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 ofgetBaseBall
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!mongst
10,841 Pointsmongst
10,841 PointsYes! As Jennifer Nordell Said your code should look like this: