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 trialKenneth Emmanuel Kouadio Ziguy
Courses Plus Student 1,125 PointsHangman game
Why did Graig create the game instance in the Hangman.java why not create it in Prompter.java
1 Answer
Dave Jindal
4,000 PointsHey Kenneth,
that's most likely because the Hangman class is like the top level of the application. It's the casing so to speak. In it, there is the main method, which is the entry point of your application.
The game class, is just for the game logic, for example where you will have the variables that represent the state of the game.
The prompter class will be there to handle the input and output. This means it will display information and also read information to/from the user.
So what you actually want is to create an instance of the game and also an instance of the prompter, which will act as a mediator between the user and the "game". The game though, is not a part of the prompter and therefore doesn't belong inside of the Prompter class.
I hope i could clear things up, if not, maybe you want to narrow down your question a little bit.
Cheers, Dave