Listener is open for basic dependency injection for tests and the reader is closed at program exit. Updated To-Do and feature lists to reflect changes.
Updated to-do list for Listener feature
Renamed Listener to TakeInput, added RequiredInputs interface, added …
…test for TakeInput, need to fix broken classes as a result of Listener refactor
Listener opened for DI for testing. Set reader back to BufferedReader…
…. Passes unit test.
Closed Listener at program exit
Fixed InputValidator tests, updated To-Do and Feature lists for compl…
…eted Listener feature
This is incorrect. You're creating a new instance and then closing the reader that belongs to that one, not the one you used to populate the String userInput. If you explore some profiling tools, you should be able to diagnose a memory leak and see that you've nicely written a virus. :)
What you need to do is retain an instance of the original listener you create to get the user's input string (as opposed to getting a new one every time) and then call closeListener on that original instance.
Remember that object creation is expensive and needs to be carefully managed.
You should hang on to the reference of the Listener you create and keep calling getInput() on that one, not create a new one every time.
Listener inputGrabber = Listener.create();
String firstInput = inputGrabber.getInput();
String secondInput = inputGrabber.getInput();
This isn't quite there. Clean up the issues in the comments.