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 trialDonald Meeks
562 PointsWhere do I find this information?
I have been stuck on this for a week. I have rewatched the videos but I have no idea what they want from me.
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) {
tiles+=tiles;
// TODO: Add the tile to tiles
}
public boolean hasTile(char tile) {
// TODO: Determine if user has the tile passed in
return false;
}
}
1 Answer
Patrik Horváth
11,110 PointsHi,there you are
Challange 1 of 2 :
Here you have to combine existing string with new one :)
public void addTile(char tile) {
// TODO: Add the tile to tiles
this.tiles += tile;
}
Challange 2 os 2:
Here you have to use indexOf method :) -http://docs.oracle.com/javase/9/docs/api/java/lang/String.html#indexOf(int)
public boolean hasTile(char tile) {
// TODO: Determine if user has the tile passed in
return tiles.indexOf(tile) >= 0;
}
Donald Meeks
562 Pointsokay I feel like that was something from another lesson
Simon Coates
28,694 PointsHi Donald, there will be some points at which information might seem missing. If you have an issue, chances are several hundred other users had the same one (unless it's a brand new or exotic course). For example, there are 4 pages of posts related to just that one challenge (see https://teamtreehouse.com/community/code-challenge:16142 ). Some of these will include answer code and high quality explanations. The treehouse forum is searchable and also google indexed, which assists tracking down someone with the same issue.
Simon Coates
28,694 PointsSimon Coates
28,694 Pointsthere's an index of method on string that accepts a character (see http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#indexOf(int) ) or look at other people's answers on that task (eg https://teamtreehouse.com/community/i-cant-find-the-error-in-the-hastile-method has a good explanation)