Need to create a “choose your own adventure” type guide - best approach to use

假装没事ソ 提交于 2019-12-06 01:46:55

问题


Basically need to ask user a set of questions and gather information along the way. Each question could have impacts on different questions down the road. Another example would be turbo tax's web interface, answering yes on some ?s may trigger future questions.

Seems like this would be a fairly common problem in software so I guess I'm asking if there are any existing solutions/Design Patterns out there that could help. Kind of seems like a state machine, but I think that is an oversimplification.


回答1:


State pattern




回答2:


Look at this picture which helps with choosing correct fonts which is called So You Need a Typeface (big image there!).

It asks you numerous questions and at some point suggest you one or several answers.

As I understand you want to create something similar but interactive and about another domain.

So, you need to construct similar graph with branching-nodes and leaf-nodes. It can be done very conveniently with the Composite pattern. If you already have (know) all possible questions (or if you know that at some point you will know all of them and will be able to add them manually to the system) then it's the way to go.

If you want something more dynamic and intelligent then the solution can highly vary from case to case.



来源:https://stackoverflow.com/questions/3333372/need-to-create-a-choose-your-own-adventure-type-guide-best-approach-to-use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!