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

creating an mvp

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

Here is my solution where do i have an error

ScrabblePlayer.java
public class ScrabblePlayer {
    private String mHand;

    public ScrabblePlayer() {
        mHand = "";
    }

    public String getHand() {
       return mHand;
    }

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


    }

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

2 Answers

Joe Killick
Joe Killick
3,714 Points

public void addTile(char tile) { mHand += tile; }

Ivan Sued
Ivan Sued
5,969 Points

Basically your code is assigning a member variable to a method/function. What you want is to use the char that is being passed and assign it to the member variable. No need for an extra function.

That function is a getter which you would use if you wanted to obtain the value of the member variable for that instance.