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

Michel Bourgeois
Michel Bourgeois
731 Points

For this first task, modify the addTile method so that it appends the tile that was passed in

Hello everyone!!!!!! i do not know if it is me but i m really struggling doing those exercises!!! i started looking at the question and what i know that i have to modify the addTitle() method

so that it appends the tile that was passed in....... i guess public ScrabblePlayer() right ?????

i have been looking on the internet and found a lot of post from 2 years ago so that is why i come up with MHand += title "";

but to be honest i have no CLUE AT ALL!!!!!!!! who came up with mHand (m for member i guess) well i could pick any other variable. could someone explain me in plain English PLEASE!!!! just help me understand!

would appreciate!!!!! thanks!

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;
  }

}

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi Michael! Some of these courses have been redone since then and challenges have been updated accordingly. So the solution you found earlier will not work here. But let's take a good look at the instructions.

For this first task, modify the addTile method so that it appends the tile that was passed in, to the player's tiles. Practice using the += shortcut method for string concatenation.

First, locate the addTile method. This is where your code will go.

And if you look at the beginning code, it even has comments to indicate where you should write your code.

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

  }

So we're going to put our code in this section. Then it says that we need to append the tile to the tiles using the += shortcut.

  public void addTile(char tile) {
    // TODO: Add the tile to tiles
        tiles += tile;  // this is the same as saying tiles = tiles + tile;  but using a shortcut as required
  }

Tip :bulb: When doing these challenges try and take it one step at a time and do exactly what the challenge asks for. Also, try not to do anything not explicitly requested for by the challenge. Even if functional, it can cause the challenge to fail.

Hope this clarifies things! :sparkles:

It worked for me! Thank you, Jennifer Nordell. I find that I'm over thinking these challenges sometimes and writing way to much code.