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

Bhawani Shankar
Bhawani Shankar
954 Points

Please help me do no answer just give me hints how to do this one .

I want to to this code by my own just guide me i am lost:(

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

  public ScrabblePlayer() {
    tiles = "";
  }

  public String getTiles() {
    return tiles;
  }

  public void addTile(char tile) {
    // TODO: Add the tile to tiles

  }

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

}
Ben McDowell
Ben McDowell
1,784 Points

So to start this, you'll need to maintain the players hand as "tiles".

The methods from your snippet show that your going to need to manipulate that string in a couple of different ways. I'd check out the java documentation on how to do that.

That's not super helpful, but I'd need more information about what you are stuck on.

Steven Sullivan
Steven Sullivan
11,616 Points

You want the tile from (char tile) to be added the String called tiles.

Add tile, to tiles.

Try some operators between the two that would add them. Be sure to end with a semicolon.

Bhawani Shankar
Bhawani Shankar
954 Points

// TODO: Add the tile to tiles Do this for me

Steven Sullivan
Steven Sullivan
11,616 Points

tile += tiles;

I might have it backwards, it might be tiles += tile;

Bhawani Shankar
Bhawani Shankar
954 Points

can you explain how Scrabble is played?

Steven Sullivan
Steven Sullivan
11,616 Points

Scrabble is a board game where each player (2-4) pulls 7 random tiles from a bag, each tile is a letter from the alphabet. There's multiple tiles for each letter, so a player can have any combination of letters.

In a clockwise or counterclockwise rotation, players begin using their tiles to form words on the board for points. The longer the word, or the higher the modifier on the space you play your tiles on the board, the more points you get.

After a word is played, the following player forms a word that is connected to a word played on the board, utilizing a letter from it.

The game is over when nobody can form any more words, and the player with the highest score wins.