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 trial

Java Java Objects (Retired) Creating the MVP Storing Guesses

Problem with task 2 of the Storing Guesses Challenge

I would assume this would work. Pretty sure I misunderstood the instructions. Help would be appreciated.

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) {
  if((mHand.contains(tile)) {
    return true;
  }
  else {
    return false;
  }
}

}

1 Answer

You might consider using the .indexOf() method for this test, as shown in the video.

Oh, whoops. I sure feel stupid now. Thanks.

Don't feel stupid! I did the same thing. I tried for a while to use a Character method. I could get them to work in terminal, but they were not the right application for the challenge.

Haha, thanks for the support my friend, it means a lot. As I go on, it's making more sense to me and I feel slightly less and less stupid. Guess it's just a part of the learning process. :)