Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class Counter
- {
- boolean stopTimer = false ;
- Timer timer; // creating new timer
- // constructor intitializes amount of seconds
- public void Counter()
- {
- timer = new Timer();
- timer.schedule(new countdown(), 5*1000);
- int choice = keyboard.nextInt();
- if(choice == 1)
- {
- timer.cancel();
- playGame();
- }
- }
- class countdown extends TimerTask
- {
- @Override
- public void run()
- {
- if(!stopTimer)
- {
- System.out.format("Returning to main menu%n");
- stopTimer = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement