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 (Retired) Creating the MVP For Each Loop

Brian York
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brian York
UX Design Techdegree Graduate 14,036 Points

Finally stumped on this "for each" Challenge.

I'm fairly unsure where to start here. Most of the challenges I've been able to piece together contextually the correlation between functions in the video and the challenge. I'm just staring at the screen now realizing the functions are too alien in difference between the Get Progress video and this one for me to even begin.

I suppose I'd begin with "public int getTileCount(char num) {}" but then I'm just stuck.

ScrabblePlayer.java
public class ScrabblePlayer {
  private String mHand;

  public ScrabblePlayer() {
    mHand = "";
  }

  public String getHand() {
   return mHand;
  }

  public void addTile(char tile) {
    // Adds the tile to the hand of the player
    mHand += tile;
  }

  public boolean hasTile(char tile) {
   return mHand.indexOf(tile) > -1;
  }
}

1 Answer

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

Hi there! I made a post about 4 months ago that seems to have helped some understand the logic behind this function and how it's accomplished. Take a look here and see if it helps you as well. Good luck! :sparkles: