Uses 911K of libraries. Click here for Pure Java version (13905L/73K).
!7 static LS questions = ll( "What's your name?", "Do you have a car?", "Do you have a girlfriend?", "Do you own a boat?", "Are you tired?", ); concept Answer { S question, answer; } compact module AskQuestions > DynDialogWithUser { class CRUD { replace A with Answer. CRUD() { conceptClass = A; } !include #1026525 // DynCRUD Include } new CRUD crud; start { crud.start_DynCRUD(); if (empty(dialog)) newQuestion(); onUserInput(voidfunc(S input) { DialogItem q = nextToLast(dialog); if (q != null && eqic(q.author, 'Computer)) { S oldAnswer = getString(conceptWhere(Answer, question := q.line), 'answer); uniq_sync(Answer, question := q.line, answer := input); if (oldAnswer != null) if (match3_noWildcards(oldAnswer, input)) addLine('Computer, "Yes, I know."); else addLine('Computer, "I thought the answer was " + quote(oldAnswer) + "?"); else addLine('Computer, "Thanks, saved."); } }); } visual jtabs("Dialog" := centerAndSouth(super, withMargin(rightAlignedButtons("New Question", rThread newQuestion))), "CRUD" := crud.visualize()); void newQuestion { addLine('Computer, random(questions)); } // API L<Answer> concepts() { ret list(Answer); } Concepts conceptsObject() { ret db_mainConcepts(); } }
download show line numbers debug dex old transpilations
Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1020938 |
Snippet name: | Ask Questions [OK, has a fixed list of questions and chooses one randomly] |
Eternal ID of this version: | #1020938/24 |
Text MD5: | 843cc26641e537b86ae93eb231346687 |
Transpilation MD5: | 8bda3f1c0fa0b775cf09a88888297def |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-01-11 17:58:08 |
Source code size: | 1460 bytes / 55 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 426 / 2007 |
Version history: | 23 change(s) |
Referenced in: | #1020946 - CRUD for other module [read only, so only "R", no "CUD" :D] |