Libraryless. Click here for Pure Java version (2824L/18K).
1 | sclass WaitForAnswer_YesNo { |
2 | S question; |
3 | |
4 | pswappable S answer(S s) { |
5 | if (isCancelCommand(s)) ret cancel(); |
6 | if (isYes(s)) { |
7 | cancelSilently(); |
8 | ret processAnswer(true); |
9 | } |
10 | if "no" { |
11 | cancelSilently(); |
12 | ret processAnswer(false); |
13 | } |
14 | ret otherInput(s); |
15 | } |
16 | |
17 | pswappable bool isYes(S s) { ret main isYes(s); } |
18 | pswappable bool isNo(S s) { ret main isNo(s); } |
19 | pswappable S otherInput(S s) { ret "I don't understand. Yes or no?"; } |
20 | pswappable S processAnswer(bool yes) { ret "You said " + yesNo_short(yes); } |
21 | pswappable bool isCancelCommand(S s) { ret match("cancel", s); } |
22 | pswappable void cancelSilently() { print("Cancelling"); } |
23 | pswappable S cancel() { cancelSilently(); ret "Action cancelled"; } |
24 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027545 |
Snippet name: | WaitForAnswer_YesNo |
Eternal ID of this version: | #1027545/5 |
Text MD5: | f9a2b5fa4d6c9258d79bc9bb24f9969d |
Transpilation MD5: | 6e995c20ac0f362875e0600339e1ef6b |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-03-23 18:57:55 |
Source code size: | 779 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 246 / 608 |
Version history: | 4 change(s) |
Referenced in: | [show references] |