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!

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

Ricky Sparks
Ricky Sparks
22,249 Points

Have no idea what to do for this code challenge?

Does it want something like this? boolean isHit = mAnswer.indexOf(letter) >= 0;

ScrabblePlayer.java
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

    }

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

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Ricky;

I think you are trying to over think Task 1 here.

The important directions from this task are:

Can you please fill out the addTile function so that it takes the char that is passed and adds it to the mHand member field? Thanks!

Our addTile() function is accepting a char named tile, correct? If all we are attempting to do is to add that tile to mHand we can do it quickly and cleanly with mHand += tile. For Task 1 then the addTile() function winds up looking like:

    public void addTile(char tile) {
        // Adds the tile to the hand of the player
      mHand += tile;
    }

Happy coding, Ken

Ricky Sparks
Ricky Sparks
22,249 Points

Thank you that makes a lot more sense.