开发者

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

开发者 https://www.devze.com 2023-01-08 16:01 出处:网络
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 inter

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 开发者_如何学JAVAan oversimplification.


State pattern


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号