需要建立一个与QUOT;选择你自己的冒险"类型指南 - 用最好的方法自己的、最好的、建立一个、类型

2023-09-11 04:04:25 作者:以为心空

基本上需要询问用户一系列问题,并收集沿途的信息。每个问题可以有不同的问题,在道路的影响。另一个例子是涡轮增压税的Web界面上的一些回答是?的可能引发未来的问题。

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.

推荐答案

看看这张图,这有助于选择与被称为的所以你需要一个字样(大图那里!)。

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.