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

Teacher Russell
Teacher Russell
16,873 Points

Prompter.java

Are we using charAt(0) on the guess input in case the player enters more than one character? This video does cover a lot without explaining it very well. Also, I thought i got "this" in this kind of situation, but let me get this straight. "this.game" inside the Prompter constructor is referring to the private variable up top, and "game" on the other side of the equals refers to the parameter?

https://w.trhou.se/ehvj5l0ye3

1 Answer

Brendon Butler
Brendon Butler
4,254 Points

Yes.

And to your second question. Yes. this always refers to the class level variable.

Teacher Russell
Teacher Russell
16,873 Points

Thank you Mr Butler. I read something that made me think I was confused. No worries. Much appreciation.