Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create a stanby button where when user clicks the standby button, it means user is leaving the device still on but when it is left for 5 minutes, the device will automatically turns off.

This is what I have come up with so far but where do I implement the timer function?

What I have tried:

import java.util.Scanner;

public class StandbyMode {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("Standby Mode");
        System.out.println("Press 1 for Standby mode");
        System.out.println("Press 2 to disable");
        int selectedOption = scanner.nextInt();
        if(selectedOption == 1){
            System.out.println("Standby mode is enabled");

          }else {
            System.out.println("Standby Mode disabled");

        }

    scanner.close();
  }

}
Posted
Comments
Richard MacCutchan 13-Sep-17 2:27am    
You need to create the standby method and call it when the user selects the enable option. The method should then use a timer to signal when the elapsed time completes. Check the Java documentation for the available classes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900