Skip to main content
Spelling fixes
Source Link
Toby Speight
  • 88.4k
  • 14
  • 104
  • 327

It would be better practice to separate your I/O from your game logic. Your Adventure Class should not create it'sits own Scanners and manually callingcall System.out.println.

The game class should take an input stream of sorts and an output stream of sorts. Then, the class's methods would pull input from the input stream and then give output to the output stream. This allows for purely game logic to be in your game adventure class.

The main method could pass in a Scanner and System.out to the game class upon instantiation. Then, you could create unit testing classes and manually create and fill input streams so that you can control the behavior of the class automatically.

It would be better practice to separate your I/O from your game logic. Your Adventure Class should not create it's own Scanners and manually calling System.out.println.

The game class should take an input stream of sorts and an output stream of sorts. Then, the class's methods would pull input from the input stream and then give output to the output stream. This allows for purely game logic to be in your game adventure class.

The main method could pass in a Scanner and System.out to the game class upon instantiation. Then, you could create unit testing classes and manually create and fill input streams so that you can control the behavior of the class automatically.

It would be better practice to separate your I/O from your game logic. Your Adventure Class should not create its own Scanners and manually call System.out.println.

The game class should take an input stream of sorts and an output stream of sorts. Then, the class's methods would pull input from the input stream and then give output to the output stream. This allows for purely game logic to be in your game adventure class.

The main method could pass in a Scanner and System.out to the game class upon instantiation. Then, you could create unit testing classes and manually create and fill input streams so that you can control the behavior of the class automatically.

Source Link
SirPython
  • 13.5k
  • 3
  • 38
  • 93

It would be better practice to separate your I/O from your game logic. Your Adventure Class should not create it's own Scanners and manually calling System.out.println.

The game class should take an input stream of sorts and an output stream of sorts. Then, the class's methods would pull input from the input stream and then give output to the output stream. This allows for purely game logic to be in your game adventure class.

The main method could pass in a Scanner and System.out to the game class upon instantiation. Then, you could create unit testing classes and manually create and fill input streams so that you can control the behavior of the class automatically.