Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects (Retired) Creating the MVP Storing Guesses

Erik Gooding
Erik Gooding
5,665 Points

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

Jesse Gravenor
Jesse Gravenor
27,272 Points

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

Erik Gooding
Erik Gooding
5,665 Points

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

Jesse Gravenor
Jesse Gravenor
27,272 Points

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.

Erik Gooding
Erik Gooding
5,665 Points

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. :)