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 Delivering the MVP Exceptions

jay ang
PLUS
jay ang
Courses Plus Student 679 Points

Why is the return part of promptForGuess() method.

in the promptForGuess() method, what is the meaning of the return part? "return game.applyGuess(guess)" ....what does this statement means?

1 Answer

Viktor Khon
Viktor Khon
2,798 Points

I don't have a technical language to explain it properly, but I will try to explain you the answer the way I understood it, hopefully it will be helpful. So, once your run promptForGuess() method, console will ask you to input a character, based on the input the method now has to return a value, in this case it returns game.applyGuess(guess) - meaning applyGuess method that is located in Game.java, right? Compiler will then go to this method 'applyGuess()' and start running the code which checks if the input is true and false and so on. To answer your question, the meaning of the return part is to use the method in Game.java to get the logic of the game and give you the answer.

Let me know if this explanation makes sense.