Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Shubham Modi
5,799 PointsWhere am I going wrong
Can you also please help me write out the hasTile method? It should return true if the hand has the tile, and false if it doesn't. Thanks!
public class ScrabblePlayer {
private String mHand;
public ScrabblePlayer() {
mHand = "";
}
public String getHand() {
return mHand;
}
public void addTile(char tile) {
mHand += tile;
// Adds the tile to the hand of the player
}
public boolean hasTile(char tile) {
if(indexof(mHand) == 1){
return true;
}else
{
return false;
}
}
}
1 Answer

Kourosh Raeen
23,732 PointsThe method hasTile() should return true not just if indexOf() returns 1, but if it returns and number that is greater or equal to 0.