Uses 911K of libraries. Click here for Pure Java version (9223L/49K).
!7 cmodule AskMeAQuestion { S question, answer; visualize { if (empty(question)) newQuestion(); JLabel lblQ = dm_fieldLabel('question); componentPopupMenuItem(lblQ, "Suggest question...", r { inputText("Question", question, voidfunc(S s) { setField(question := s) }) }); ret withRightMargin(makeForm2( "Computer question", lblQ, "Human answer", centerAndEastWithMargin(onEnter(dm_fieldTextField('answer), rThread submit), jbutton("Submit", rThread submit)), "", withTopMargin(15, rightAlignedButtons("Ask me something else", rThread newQuestion)))); } S randomWord() { ret randomEnglishWordFromDictionary(); } S makeQuestion() { ret "Is " + randomWord() + " the same as " + randomWord() + "?"; } void newQuestion enter { setFields(answer := "", question := makeQuestion()); programLogStructure(litorderedmap(+question)); vmBus_send('showingQuestion, module(), question); } void submit enter { programLogStructure(litorderedmap(+question, +answer)); vmBus_send('userAnsweredQuestion, module(), question, answer); dm_addQAndA_infoBox(question, answer); newQuestion(); } }
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1020045 |
Snippet name: | Ask Me A Question [Computer asks, human answers, dev.] |
Eternal ID of this version: | #1020045/13 |
Text MD5: | 7550b46fcf9a40d2561850610bc57442 |
Transpilation MD5: | 21577b2a738ce6818faf462cbd5b376e |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-01-23 17:17:36 |
Source code size: | 1249 bytes / 41 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 366 / 1530 |
Version history: | 12 change(s) |
Referenced in: | #1021117 - DynAskUserQuestions #1021118 - Ask for meaning of words |