ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

UML第四次作业

2019-05-13 12:43:09  阅读:391  来源: 互联网

标签:startuml stop 作业 enduml else start UML yes 第四次


一、PlantUML活动图绘制方法

(1)开始/结束

你可以使用关键字startstop表示图示的开始和结束。 

@startuml
start
:Hello world;
:This is on defined on
several **lines**;
stop
@enduml

也可以使用 end 关键字。

@startuml
start
:Hello world;
:This is on defined on
several **lines**;
end
@enduml

 






 (2)条件语句

 

在图示中可以使用关键字ifthenelse设置分支测试。标注文字则放在括号中。

 

 

 

@startuml

start

if (Graphviz installed?) then (yes)
  :process all\ndiagrams;
else (no)
  :process only
  __sequence__ and __activity__ diagrams;
endif

stop

@enduml

也可以使用关键字elseif设置多个分支测试。

 

@startuml
start
if (condition A) then (yes)
  :Text 1;
elseif (condition B) then (yes)
  :Text 2;
  stop
elseif (condition C) then (yes)
  :Text 3;
elseif (condition D) then (yes)
  :Text 4;
else (nothing)
  :Text else;
endif
stop
@enduml

 







 (3)重复循环

你可以使用关键字repeatrepeatwhile进行重复循环。

 

@startuml

start

repeat
  :read data;
  :generate diagrams;
repeat while (more data?)

stop

@enduml

 (4)while循环

可以使用关键字whileend while进行while循环。

 

@startuml

start

while (data available?)
  :read data;
  :generate diagrams;
endwhile

stop

@enduml

还可以在关键字endwhile后添加标注,还有一种方式是使用关键字is

 

@startuml
while (check filesize ?) is (not empty)
  :read file;
endwhile (empty)
:close file;
@enduml

(5)并行处理

你可以使用关键字forkfork againend fork表示并行处理。

 

@startuml

start

if (multiprocessor?) then (yes)
  fork
	:Treatment 1;
  fork again
	:Treatment 2;
  end fork
else (monoproc)
  :Treatment 1;
  :Treatment 2;
endif

@enduml

 

(6)注释

文本格式支持creole wiki语法。

A note can be floating, using floating keyword.

@startuml

start
:foo1;
floating note left: This is a note
:foo2;
note right
  This note is on several
  //lines// and can
  contain <b>HTML</b>
  ====
  * Calling the method ""foo()"" is prohibited
end note
stop

@enduml

(7)颜色

你可以为活动(activity)指定一种颜色

 

@startuml

start
:starting progress;
#HotPink:reading configuration files
These files should edited at this point!;
#AAAAAA:ending of the process;

@enduml

(8)箭头

使用->标记,你可以给箭头添加文字或者修改箭头颜色

同时,你也可以选择点状 (dotted),条状(dashed),加粗或者是隐式箭头

 

@startuml
:foo1;
-> You can put text on arrows;
if (test) then
  -[#blue]->
  :foo2;
  -[#green,dashed]-> The text can
  also be on several lines
  and **very** long...;
  :foo3;
else
  -[#black,dotted]->
  :foo4;
endif
-[#gray,bold]->
:foo5;
@enduml

(9)连接器(Connector)

你可以使用括号定义连接器。

 

@startuml
start
:Some activity;
(A)
detach
(A)
:Other activity;
@enduml

(10)组合(grouping)

通过定义分区(partition),你可以把多个活动组合(group)在一起。

 

@startuml
start
partition Initialization {
	:read config file;
	:init internal variable;
}
partition Running {
	:wait for user interaction;
	:print information;
}

stop
@enduml

(11)泳道(Swimlanes)

你可以使用管道符|来定义泳道。

还可以改变泳道的颜色

@startuml
|Swimlane1|
start
:foo1;
|#AntiqueWhite|Swimlane2|
:foo2;
:foo3;
|Swimlane1|
:foo4;
|Swimlane2|
:foo5;
stop
@enduml

(12)分离(detach)

可以使用关键字detach移除箭头。

 

@startuml
 :start;
 fork
   :foo1;
   :foo2;
 fork again
   :foo3;
   detach
 endfork
 if (foo4) then
   :foo5;
   detach
 endif
 :foo6;
 detach
 :foo7;
 stop
@enduml

(13)特殊领域语言(SDL)

通过修改活动标签最后的分号分隔符(;),可以为活动设置不同的形状。

  • |
  • <
  • >
  • /
  • ]
  • }
@startuml
:Ready;
:next(o)|
:Receiving;
split
 :nak(i)<
 :ack(o)>
split again
 :ack(i)<
 :next(o)
 on several line|
 :i := i + 1]
 :ack(o)>
split again
 :err(i)<
 :nak(o)>
split again
 :foo/
split again
 :i > 5}
stop
end split
:finish;
@enduml

(14)一个完整的例子

@startuml

start
:ClickServlet.handleRequest();
:new page;
if (Page.onSecurityCheck) then (true)
  :Page.onInit();
  if (isForward?) then (no)
:Process controls;
if (continue processing?) then (no)
  stop
endif

if (isPost?) then (yes)
  :Page.onPost();
else (no)
  :Page.onGet();
endif
:Page.onRender();
  endif
else (false)
endif

if (do redirect?) then (yes)
  :redirect process;
else
  if (do forward?) then (yes)
:Forward request;
  else (no)
:Render page template;
  endif
endif

stop

@enduml








 

二、超市购物

流程:

顾客:选择自已所要购买的商品,并把选好的商品拿到收银台交给收银员。

收银员:询问顾客是否是会员,如果是会员,索要顾客的会员卡,把会员卡扫描进系统并对会员卡进行验证。然后逐一扫描顾客所 选商品的条形码。扫描完商品信息后,根据收款机上显示的商品金额收货款,售货单和商品交给顾客。

收款机:边接收商品条码,边累加商品金额,打印售货单。

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 @startuml |顾客| start :选择商品; :商品交给收银员; |#AntiqueWhite|顾客| if (是否是会员) then (yes) :会员; |收银员| :扫描会员卡; |#AntiqueWhite|收款机| if (接收会员编号) then (yes) :提示会员卡有效; else (no) :提示会员卡无效; endif else (no) |顾客| :非会员; endif |收银员| :扫描商品条码; |收款机| :接收商品条形码; :统计商品金额; |收银员| while (是否还有商品) is (yes) |收银员| :扫描商品条码; endwhile (no) |顾客| :交付货款; |收银员| :接收货款; |收款机| :打印售货单; |收银员| :货单及货品交给顾客; |顾客| :接收货单及货品; stop @enduml

 

标签:startuml,stop,作业,enduml,else,start,UML,yes,第四次
来源: https://www.cnblogs.com/Qinyuzhou/p/10855965.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有