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 trialKarl Comboy
1,320 PointsWhat im I doing wrong here?
Please anyone can make me clearly understand this challenge
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() {
String count = "";
for (char letter: mHand.toCharArray()) {
if (mHand.indexOf(letter) >= 0) {
count += letter;
}
}
return count;
}
}
1 Answer
Jeremy Hill
29,567 PointsYour method should look like this:
public int getTileCount(char tile){
int cnt = 0;
for(int i = 0;i < mHand.length();i++){
if(mHand.charAt(i) == tile)
cnt++;
}
return cnt;
}
Jeremy Hill
29,567 PointsJeremy Hill
29,567 PointsI haven't been following with the java track so they may be having you do it a little differently.
Karl Comboy
1,320 PointsKarl Comboy
1,320 Pointsoh my god.. thank you sir for this, yeah my solution was too far from reality sad life... you sir Jeremy is awesome thanks as always...
Jeremy Hill
29,567 PointsJeremy Hill
29,567 PointsYou're welcome, glad to help :)
Karl Comboy
1,320 PointsKarl Comboy
1,320 Pointssir Jeremy aside from tree house, you have any other page so that i can follow you? tnx ^_^
Jeremy Hill
29,567 PointsJeremy Hill
29,567 PointsI only have twitter and facebook but I don't much programming feed on either one; in fact, most of what I post is Christian-based.
Karl Comboy
1,320 PointsKarl Comboy
1,320 Pointscan i add you in Facebook sir Jeremy? were same christian (^.^)/. if its ok for you to drop some private message only..
Jeremy Hill
29,567 PointsJeremy Hill
29,567 PointsYeah you can look me up on facebook; send me a friend request.