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 trialSuciu Sorin
2,388 PointsDon't know where to start from
I have to add a method called getTileCount that uses the for each loop to loop through the characters and increment a counter if it matches? Return the count.
I need just a little hint.
Thank's
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) {
return mHand.indexOf(tile) > -1;
}
public String getTileCount(){
for(){
}
}
}
}
2 Answers
Shane Robinson
7,324 PointsWell first, you are getting a count of the tiles so you want to return an integer - not a String. Also, you are going to want to have a parameter of char
for the getTileCount()
method, so getTileCount(char param)
. I would go back and watch the previous video because it gives a pretty good explanation of the for loop that you are going to want to use - any more than that would be more than just the hint you are looking for. :p
Suciu Sorin
2,388 PointsThank's a lot! The hint i needed?