Java Java Objects Creating the MVP Scrabble Tiles

Scrabble Game : Don't know how why adding new tile is still returning false

I'm not sure how to get through this challenge. In the hasTile method, I'm getting an a prompt that say that they've tried to pass in char ('y') and it returns false. Not sure how to correct the HasTile method!

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
    tiles += "tile";

  }

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

    return tiles.indexOf(tile) != -1;

}




    }

2 Answers

This is the problem line >> tile+="tile"; It should be tile += tile;
No quotes

Oshedhe Munasinghe
Oshedhe Munasinghe
8,105 Points

The answer is

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

  }

You have to call parameter tiles.