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 Strings and Chars

Not sure what to do on challenge 2 on Scrabble char method

Hi there,

I am working on creating a scrabble game on a java challenge. I have to make it so that if a tile is in hand, it passes it as true, and if it's not, it passes it as false. Here is the code I made for the first challenge, so there is no new code for the 2nd challenge I just described. Could you help me with the necessary code for this? Thanks for the help!

ScrabblePlayer.java
public class ScrabblePlayer {
    private String mHand;

    public ScrabblePlayer() {
        mHand = "";
    }

    public String getHand() {
       return mHand;
    }

    public void addTile(char tile) {
      boolean hasTile = mHand.indexOf(tile) >= 0;
      mHand += tile;
        // Adds the tile to the hand of the player

    }

    public boolean hasTile(char tile) {
       return false;
    }
}

1 Answer

David Axelrod
David Axelrod
36,073 Points

Hey Gabriel!

You're almost there!! Few things!

1) You were still typing in the addTile method instead of the has tile method. Move that boolean line down to the other method 2) now you have the true or false data of whether or not the block is in your hand! Just return it and you're done!