nus-cs2113-AY1920S2 / forum

4 stars 0 forks source link

Error with Text-ui-testing multiple lines in input.txt #105

Closed dejunnn closed 4 years ago

dejunnn commented 4 years ago

image

The following error occurs when I enter more than 1 line in input.txt. Im not sure why this is happening and what I can do to solve it.

I tried methods recommended by other forum posts such as deleting old jar files and running gradlew clean but nothing seems to work. Would really appreciate any help. Thanks!!!

damithc commented 4 years ago

Compare how other teams use the Scanner object to the way you guys use it.

dejunnn commented 4 years ago

Oh, I think I managed to figure out the issue already. I honestly have no idea what I did to fix it but I messed around with it a little and now it works. Thanks a bunch! :)

damithc commented 4 years ago

Oh, I think I managed to figure out the issue already. I honestly have no idea what I did to fix it but I messed around with it a little and now it works. Thanks a bunch! :)

The Scanner object should be created only once and kept in a static variable. In your code you created a new Scanner for each input. The very first Scanner swallows all the inputs from the file, and the second one throws 'No lines found' error.