1

我想创建一个 FSM 图,并想为此使用 Plantuml。我坚持使用向后箭头
有一种方法可以创建向后箭头,但对于这样一个简单的任务来说,它看起来过于复杂且过于有限

@startuml
:start;
repeat :Ask to enter login;
repeat while(Is name valid?) is (No) not (Yes)
:play game;
@enduml

这给出了这个
在此处输入图像描述

但是当你想实现一些更复杂的逻辑时,比如:

  1. 要求输入姓名
  2. 要求输入密码
  3. 在第三次尝试失败时返回 (1)

看起来它只是不可能用植物

我不知道它是否称为状态图,但我查看了 Plantuml 支持的所有类型的图表,它似乎是最合适的

4

1 回答 1

0

我会说活动图效果最好。

您所描述的内容很容易解释,但在正确的 UML 中显示很复杂,我认为这不是特定于植物的。以下是我将如何表达你所说的话:

PlantUML 活动图

@startuml
start
while (App) is (running)
  :enter username;
  repeat
    :enter password;
    if (Password correct?) then (yes)
      :Play game;
      stop
    endif
  repeat while (Third attempt?) is (no) not (yes)
endwhile (exit)
stop
@enduml
于 2021-07-20T14:15:52.403 回答