Welcome to the Treehouse Community
Looking to learn something new?
Eric Park4,557 Points
Calling a method
Hi, I was wondering why we have to type in Prompter.play() instead of mGame.play(). I am confused because play is not a static method, and yet we call it using the Prompter class.
Grigorij Schleifer10,363 Points
we call promter.play(); (prompter is lowercased).
Inside our Hangman class we create an instance of the Prompter class and call it "prompter". In other words "prompter" is the object of the Promter class. We need this instantiation for accessing the methods of the Prompter class like play() through the dot Operator (.).
Would be play() a static method, you could use it without creating a instance/object of the Prompter class.
I hope I could clear things a little bit up....