I am working on a card game and I need to get the user input from the console. To do so, I am using the class Scanner, more specifically the method nextInt(). But, if the user does not provide an option within 60 seconds, the system should be able to select one randomly. I would like to know if there is a way to "cancel" the previously made call to the method nextInt() and use the one generated by Random.nextInt() instead.
The code responsible for it is:
System.out.print("Enter the number of your choice");
option = scanner.nextInt();
I have read about ways to do it using GUI, but in my case, I am not planning on having one.
Thanks
EDIT1:
I have been doing some research on this and I believe that monitoring the keyboard for the pressed keys would solve my problem, I am now working on finding out how to monitor the keyboard and get the pressed keys. Can anyone help me with that?