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 Creating the MVP Scrabble Tiles

can someone explain to me how this works?

Im so stressed right now can someone help

ScrabblePlayer.java
public class ScrabblePlayer {
  // A String representing all of the tiles that this player has
  private String tiles;

  public ScrabblePlayer() {
   mHand+= tiles " " ;
  }

  public String getTiles() {
    return tiles;
  }

  public void addTile(char tile) {
    // TODO: Add the tile to tiles
      public getHand = mHand;
  }

  public boolean hasTile(char tile) {
    // TODO: Determine if user has the tile passed in
    return false;
  }

}

1 Answer

Chris Jones
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Jones
Java Web Development Techdegree Graduate 23,933 Points

Hey Alex!

The task is to add/concatenate the tile (a char parameter) passed into the addTile method to the class field tiles, which is a string (a concatenation of chars).

The tiles field is private, but you can access it from the class' own methods without a getter. Second, access modifiers, like public and private are only needed on classes, methods, and fields, not on lines of code inside a method body. There's also no need for a mHand variable, so you can delete that.

Let me know if that helps you down the right path.

Let me know if you have any more questions!