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

36
LINES

< > BotCompany Repo | #1000890 // "what time is it" (test case on #1000887, works)

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

Libraryless. Click here for Pure Java version (1849L/15K/44K).

1  
!747
2  
3  
m {
4  
  static Class prog;
5  
  
6  
  p {
7  
    prog = hotwire("#1000887");
8  
    
9  
    setClock(15, 34);
10  
    ask("what time is it?");
11  
    expect("It is 15:34.");
12  
  }
13  
  
14  
  static void setClock(int h, int m) ctex {
15  
    long now; // (h*60+m)*60*1000L
16  
    Date date = new java.text.SimpleDateFormat("HH:mm").parse("15:34");
17  
    now = date.getTime();
18  
    print("date: " + date + ", now: " + now);
19  
    setOpt(prog, "now_virtualTime", now);
20  
  }
21  
  
22  
  static void ask(S q) {
23  
    set(prog, "question", q);
24  
    callMain(prog);
25  
  }
26  
  
27  
  static void expect(S a) {
28  
    S answer = cast get(prog, "answer");
29  
    if (a.equals(answer))
30  
      print("OK: " + answer);
31  
    else {
32  
      print("Wrong: " + answer);
33  
      print("Expected: " + a);
34  
    }
35  
  }
36  
}

Author comment

Began life as a copy of #1000875

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1000890
Snippet name: "what time is it" (test case on #1000887, works)
Eternal ID of this version: #1000890/1
Text MD5: ec5988cb60af578798ee73a4b68aac54
Transpilation MD5: 7f9028a57a68d9cf511a965e00d21d96
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-09-05 18:46:01
Source code size: 763 bytes / 36 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 575 / 642
Referenced in: [show references]