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

Nikhil Sharma
Nikhil Sharma
1,173 Points

can you help with this code !

i tried but cant get through , anyone help me with this !

ScrabblePlayer.java
public class ScrabblePlayer {
  private String mHand;
  public int getTileCount(char tile){
    int mCount=0;
    for(char tiles:mHand.toCharArray())
      return mCount++;
                                    }

  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

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Make sure you check all answers to this topic, by clicking 'For Each Loop' loop above your question, or this link

https://teamtreehouse.com/community/code-challenge:6002

Couple of good ones from that list:

https://teamtreehouse.com/community/i-have-no-idea-how-to-do-this-challenge

https://teamtreehouse.com/community/i-dont-understand-why-shows-me-this-result

Let me know if that questions helped....

It is also good idea to check "Question" tab before to the video before

https://teamtreehouse.com/library/java-objects/creating-the-mvp/current-progress

There you can find a lot of people struggling the same. I wanted to show you because that can help you with furthere challenges as well