I don't have the code currently on me (at home right now, and code is on school computers), but I should be able to explain my problem.
I'm using the SavitchIn class to read input from the user. I have code setup so that it asks the user to press enter (using SavtitchIn.read Line() ) and then proceeds to run a loop that basically pauses the system for 5 seconds after the user presses enter, after the 5 seconds the word "BEGIN!" flashes onto the console and with SavitchIn.readL ine() called again the user begins typing a specified sentence. The object of the program is to see how fast the user can type the sentence. Now my problem is that for some reason, during the loop that pauses the system for 5 seconds the user is able to type and have whatever they typed suddenly show up as soon as the SavitchIn.readL ine() is called after "BEGIN!". In effect, the user can cheat the game and type the entire sentence and just hit enter before Begin! even flashes and this will all be saved and read in the next calling of SavitchIn.readL ine(). How do I fix this? I figure there must be some way to clear the input stream, but attempts of google searching have just left me frustrated.
Please help,
Michael
I'm using the SavitchIn class to read input from the user. I have code setup so that it asks the user to press enter (using SavtitchIn.read Line() ) and then proceeds to run a loop that basically pauses the system for 5 seconds after the user presses enter, after the 5 seconds the word "BEGIN!" flashes onto the console and with SavitchIn.readL ine() called again the user begins typing a specified sentence. The object of the program is to see how fast the user can type the sentence. Now my problem is that for some reason, during the loop that pauses the system for 5 seconds the user is able to type and have whatever they typed suddenly show up as soon as the SavitchIn.readL ine() is called after "BEGIN!". In effect, the user can cheat the game and type the entire sentence and just hit enter before Begin! even flashes and this will all be saved and read in the next calling of SavitchIn.readL ine(). How do I fix this? I figure there must be some way to clear the input stream, but attempts of google searching have just left me frustrated.
Please help,
Michael
Comment