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 trialCaleb Seeling
1,189 PointsCant 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!
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
Treehouse Moderator 145,860 PointsHey 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! :)