Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

27
LINES

< > BotCompany Repo | #1000733 // Talk when battery level crosses 5% boundaries

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 13052K of libraries. Click here for Pure Java version (744L/6K/20K).

!636 (modern)

main {
  static boolean kevinOn = true;
  
  psvm {
    int b = getBattery();
    say(b + " percent");
    int last = b;
    print("I'll be monitoring the battery every 10 seconds.");
    while (true) {
      sleep(10000);
      b = getBattery();
      if (b/5 != last/5) {
        say(b + " percent");
        last = b;
        print("I'll keep checking the battery every 10 seconds...");
      }
    }
  }

  static void say(String s) {
    print(s);
    if (kevinOn)
      try { kevin(s); } catch (Throwable e) { e.printStackTrace(); }
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1000733
Snippet name: Talk when battery level crosses 5% boundaries
Eternal ID of this version: #1000733/1
Text MD5: 0d84ff07befea199f53d09e8a94cc367
Transpilation MD5: d77bcf10d50307a3c73ffdb879f2c79f
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-10-11 20:30:09
Source code size: 587 bytes / 27 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 702 / 736
Referenced in: #3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)