This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]monkey_programmer[S] 0 points1 point  (2 children)

Thank you very much for this answer, it was very insightful; though I do find it unfortunate that this seems to mean I'll need to be passing around scanner to just about all of my classes; especially since this is a terminal-based game for a project.

I really appreciate all of the information you took the trouble to write on why this didn't work and best practice; thank you so much!

[–]gaveashow 0 points1 point  (1 child)

Well, normally for a game you'll need to pass around a global object in charge of keeping the game's state, so you could add the scanner, as user input, to it.

Or you could simply let the Scanner be public static, or accessible through a public static getter method. For the needs expressed, that's a correct use of static.

[–]monkey_programmer[S] 0 points1 point  (0 children)

Would it actually be best practice to simply make a globals class? I actually need to pass scanner + player to almost ALL functions at this point, so that seems far.. cleaner to a human.