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 trialAlexandru Dinu
13,633 PointsWhy is this error message: "Bummer! Hmmm, remember that you can add chars to an existing String using the += method."
on this piece of code: mHand += letter; ?
public class ScrabblePlayer {
private String mHand;
public void addTitle(char letter){
mHand += letter;
}
public ScrabblePlayer() {
mHand = "";
}
public String getHand() {
return mHand;
}
public void addTile(char tile) {
// Adds the tile to the hand of the player
}
public boolean hasTile(char tile) {
return false;
}
}
2 Answers
Stephen Shine
5,991 PointsI think the main problem is the mis-type in your method name. It's called addTitle, rather than addTile. Probably the test can't fund the right method to carry out. You can use the code that you've written, but put it under the comment in the example you've given.
Jeremy Hill
29,567 PointsIt wants you to make the method add to the existing hand of tiles. Simple code would be to say:
mHand = mHand + tile;
// the short hand way of doing this is:
mHand += tile;
make sure you do this inside the method addTile()
Alexandru Dinu
13,633 PointsAlexandru Dinu
13,633 PointsYap, that was the problem. Thx