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

i have count and i get a result from console, i don`t know what else try to pass the test.

they ask for a character counter, and i made it, they ask to make a method and use de for loop and i did and use the .toCharArray () function. but i dont know what else do. also im from Argentina, english is not my native language so there are things that are dificcult to understand.

so if theres anyone how speaks spanish would be great

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

  public void getTileCount(char display){
  String msg = " ";
    int counter = 0;
    for (char tile : mHand.toCharArray()){

      if (mHand.indexOf(tile) >= 0){
      display = tile;
        msg += display;
        counter++;
      }
    }
  System.out.printf("El mensaje es: %s\n", msg);
    System.out.printf ("el puntaje es %d\n", counter);

  }
}

1 Answer

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Did you change that method signature? It should return an int right?

Let me know if that hint doesn't help ;)