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 trialMark John
Courses Plus Student 771 Pointsplz i need help with this java challenge question
the question => "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 dosen't."....plz i need assistance with this question
public class ScrabblePlayer {
private String mHand;
public ScrabblePlayer() {
mHand = "";
}
public String getHand() {
return mHand;
}
public void addTile(char tile) {
// Adds the tile to the hand of the player
mHand += tile;
}
public boolean hasTile(char tile) {
addTile(char tile);
if (addTile(char tile)) {
return true;
}else{
return false;
}
}
}
3 Answers
Geovanie Alvarez
21,500 PointsOk in the hasTile method do this
public boolean hasTile(char tile) {
return mHand.indexOf(tile) > -1; // this will return true if the tile found in the mHand variable
}
Furquan Ahmad
5,148 PointsOn the addTile line you need to declare a boolean variable. So : boolean addTile(char tile);
Mark John
Courses Plus Student 771 Pointsthanks everyone! i appriciate!