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).

1  
!636 (modern)
2  
3  
main {
4  
  static boolean kevinOn = true;
5  
  
6  
  psvm {
7  
    int b = getBattery();
8  
    say(b + " percent");
9  
    int last = b;
10  
    print("I'll be monitoring the battery every 10 seconds.");
11  
    while (true) {
12  
      sleep(10000);
13  
      b = getBattery();
14  
      if (b/5 != last/5) {
15  
        say(b + " percent");
16  
        last = b;
17  
        print("I'll keep checking the battery every 10 seconds...");
18  
      }
19  
    }
20  
  }
21  
22  
  static void say(String s) {
23  
    print(s);
24  
    if (kevinOn)
25  
      try { kevin(s); } catch (Throwable e) { e.printStackTrace(); }
26  
  }
27  
}

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: 632 / 647
Referenced in: [show references]