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 Creating the MVP Prompting for Guesses

Md shujaul Haque
Md shujaul Haque
839 Points

return game.applyGuess(guess) how this work and guess is pass to another method ? dont understand this line .

In prompt class

return game.applyGuess(guess) how this is working, did not understand this line of code and how "guess" passing through ?

1 Answer

Randy Duncan
Randy Duncan
1,026 Points

In an application code is executed line by line so he already declared that the char that accepts the argument of guessInput which is "0" , he named that guess....so once the code in that line is executed it then moves on to the last line in the method with the return value... being that the guessInput is already assigned to the variable guess in the promptForGuess scope he can now use it any where after he declared it as long as its in that scope..... so in theory when the executed line 14 he can use it in any line after which is what he did, he called the applyGuess method from the game class and he the passed in the guess that was assigned. Hope that helps as i'm also learning and i'm not a master yet.