r/javahelp•
Hanhula

Program seems to be skipping over lines of Scanner input from file; is something wrong with how I'm processing this?

I'm doing a basic Java course and I've run into an issue with the latest assignment. The assignment itself is to use a custom library to replay a game of Othello, wait times included, on a 8x8 grid (a - h on the x axis, 1 - 8 on the y).

I'm able to run my code perfectly fine, and it seems to run well... other than the fact that it's skipping over some of the lines of input, and not displaying things properly in the program.

https://pastebin.com/m379Hm7D Here's the code I've thrown together. https://pastebin.com/f3KCkXDf And to make sense of it, here's some of the input.

When I run it, it's meant to start off with the 4 first tokens staying in place, before playing out a generic game of Othello. Instead, it.. places two of the black ones at their correct spots and ignores any white tokens for a while, moves a few black tokens around, then starts placing things semi-accurately.

I've tried changing the order of the loops, added in the separate method for the first four lines, changed my method of parsing String into char into int completely, played around with basic maths as it seems adding -1 to the non-starting method is the only way I can get it to place in the right spots for some ungodly reason, used a For loop for the first four (which broke the program completely), and have cleaned up my code so that xplace and yplace exist (before, I just wrote out the individual code each time).

Is there something very obvious that I'm missing with this to get it to properly read the input from the file? I've coded in C++ before, but never Java, and didn't touch on file i/o too much in my C++ course.

Quick Edit: Is it possible that it's something to do with the ui.wait class? Is there a way to force Java to not continue to the next line until the right amount of time has elapsed..?

Posted Oct 13, 2017, 8:16 AM UTC

12
Loading comments…