Java USSD菜单树生成 - 如何 [英] Java USSD menu tree generation - how to

查看:96
本文介绍了Java USSD菜单树生成 - 如何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Java生成一个基于树的菜单,该菜单将出现在USSD浏览器上。每个节点可能有子节点,以叶节点结尾。我还必须维护每个访问此菜单的用户的状态(比如他在菜单上的当前位置)以方便导航。

I want to generate a tree-based menu using Java that will appear on a USSD browser. Each node may have children, ending with leaf nodes. I will also have to maintain state regarding each user who accesses this menu (like his current position on the menu) to facilitate navigation.

关于如何实现树生成和状态管理?

Any ideas on how I may achieve the tree generation and state management?

推荐答案

我假设你从网关收到一条消息,例如:
(Session) #,UserInput)
你需要计算下一个要发送给用户的信息吗?

I assume that you get a message from the gateway such as: (Session#, UserInput) and you need to compute the next information to send to the user ?

我建议:


  1. 表CURRENTSTATE:

    会话#

  1. table CURRENTSTATE:
    Session#
    State

表状态:

状态

标题

table STATES:
State
Title

表格选择:



选择

名称

DoCode

NewState

table CHOICES:
State
Choice
Name
DoCode
NewState

然后当你收到消息(Session#,UserInput)时:

Then when you get the message (Session#, UserInput):


  1. 使用Session查询CURRENTSTATE #确定用户所处的状态。

  2. 使用State和Choice = UserInp查询CHOICES根据用户输入确定新状态(和DoCode)。

  3. 基于DoCode,您可以进行一些处理。

  4. 将CURRENTSTATE更新为反映新状态。

  5. 查询STATES获取标题(例如请选择一种颜色。

  6. 查询选择以获得新状态的可能选择(例如(1,蓝色),(2,红色)等。 )

  7. 构建消息(concat Title + choices)

  8. 向用户返回消息。

  1. query CURRENTSTATE using the Session# to determine what state the user is in.
  2. query CHOICES using the State and Choice=UserInput to determine the new state (and DoCode) based on user input.
  3. Based on DoCode, you can do some processing.
  4. update CURRENTSTATE to reflect the new state.
  5. query STATES to get the Title (e.g. "Please choose a color").
  6. query CHOICES to get the possible choices from the new state (e.g. (1, "Blue"), (2, "Red"), etc.)
  7. build the message (concat Title + choices)
  8. return message to user.

这是解决问题的合理方法吗?

Is that a reasonable way to solve the problem ?

这篇关于Java USSD菜单树生成 - 如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆