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 trialEthan Smith
877 PointsWhat am I doing wrong?
whats wrong with this code?
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 TYPE getTileCount(ARGUMENT); {
for (char ITERATOR: mHand.toCharArray()) {
if(EXPRESSION) {
}
}
}
1 Answer
Jonathan Petersen
45,721 Pointspublic TYPE getTileCount(ARGUMENT); {
for (char ITERATOR: mHand.toCharArray()) {
if(EXPRESSION) {
}
}
The problem is this method. You need to change TYPE, ARGUMENT, EXPRESSION. You dont have to change the word ITERATOR, but you probably should.
- The 'TYPE' is the return type for this method, probably an int
- The 'ARGUMENT' is the variable that accept input into the method.
- The 'EXPRESSION' should check if the 'ITERATOR' is equal to the char passed in as an argument
- You are missing one closing bracket.
- Right after the argument parenthesis you have a semi-colon, that shouldn't be there.
I think this should get you started, Let me know if you need anything else.