You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I made an enhancement that prompts the user for name, phone, email, address & tags one by one as shown below. This passes manual testing, however it returns “NoSuchElementException: No line found” if I use file redirection with input.txt instead.
the compile error
Here's what input.txt looks like:
Seems like it's something to do with Scanner.nextLine() not detecting a next line, but nextLine() is the only way to read in strings with spaces in them. Any idea what is causing this?
The text was updated successfully, but these errors were encountered:
When using the I/O method of testing, you should not create multiple scanners. Reason: all input text (given in one shot via the file) is swallowed by the first Scanner, leaving nothing for the subsequent scanners.
On a general note, the current code is tailored for a CLI interface where each command is stand-alone. Prompting for user input is hard to fit into the current code base, unless you put the code somewhere it doesn't belong, such as what you have done. :-p i.e. Interacting with the user should not be done in one place rather than all over the code base.
EDIT: should not be -> should not be
Oh yeah I tried to get the existing system to accept user inputs one by one, but found it too complicated to modify (hence the cheap hack with creating a new class to tack onto the existing 'add person' method).
Here's the relevant PR: https://github.com/nus-cs2103-AY1718S1/addressbook-level2/pull/400
I made an enhancement that prompts the user for name, phone, email, address & tags one by one as shown below. This passes manual testing, however it returns “NoSuchElementException: No line found” if I use file redirection with input.txt instead.
the compile error
Here's what input.txt looks like:
Seems like it's something to do with Scanner.nextLine() not detecting a next line, but nextLine() is the only way to read in strings with spaces in them. Any idea what is causing this?
The text was updated successfully, but these errors were encountered: