Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects (Retired) Creating the MVP Current Progress

Michelle Vanwagenen
Michelle Vanwagenen
5,614 Points

What does it mean when is says a "create the method getTileCount that excepts a char?"

In reference to the For Each Loop code challenge. I feel like I'm so close, but this is the correction it gives me. I am just getting more confused.

2 Answers

Hi Michelle - I'm not sure whether you're looking for a detailed explanation or just a hint in the right direction, but you need to create a getTileCount() method that accepts a char as an argument and then uses a loop to get a count of tiles with the character you specify. For example, if you called the method as getTileCount('a'), the method would loop through the tiles in your hand and count each 'a', then return that number.

Hi Kathryn, I seem to be stuck as well. When creating the getTileCount() method, would you declare it like so: public int getTileCount(char foo){ } ?

The reason I added the int is because I assumed the output of the method will be a number of how many times that character is found within the player's tiles?

Michelle Vanwagenen
Michelle Vanwagenen
5,614 Points

Thank you Kathryn, I really just wanted a hint. I didn't understand the part where it talks about accepting the character. You listed above that it is an argument. I was able to rethink what was being asked and applied it correctly. Thank You!!

Hi Emanuel - You might have figured out your answer already, but yes, that looks like the correct way to declare the method!