第一部分:PlantUML用例图 语法学习小结
用例
用例用圆括号括起来,也可以用关键字usecase来定义用例。还可以用关键字as定义一个别名,这个别名可以在以后定义关系的时候使用。
@startuml
(First usecase)
(Another usecase) as (UC2)
usecase UC3
usecase (Last\nusecase) as UC4
@enduml
如果想定义跨越多行的用例描述,可以用双引号将其裹起来。还可以使用这些分隔符:--..==__。 并且还可以在分隔符中间放置标题。
@startuml
usecase UC1 as "You can use
several lines to define your usecase.
You can also use separators.
--
Several separators are possible.
==
And you can add titles:
..Conclusion..
This allows large description."
@enduml
角色
角色用两个冒号包裹起来,也可以用actor关键字来定义角色。还可以用关键字as来定义一个别名,这个别名可以在以后定义关系的时候使用。
@startuml
:First Actor:
:Another\nactor: as Men2
actor Men3
actor :Last actor: as Men4
@enduml
用箭头-->连接角色和用例,横杠-越多,箭头越长。
通过在箭头定义的后面加一个冒号及文字的方式来添加标签。
@startuml
User -> (Start)
User --> (Use the application) : A small label
:Main Admin: ---> (Use the application) : This is\nyet another\nlabel
@enduml
继承
如果一个角色或者用例继承于另一个,那么可以用<|--符号表示
@startuml
:Main Admin: as Admin
(Use the application) as (Use)
User <|-- Admin
(Start) <|-- (Use)
@enduml
注释
可以用note left of , note right of , note top of , note bottom of等关键字给一个对象添加注释。注释还可以通过note关键字来定义,然后用..连接其他对象。
@startuml
:Main Admin: as Admin
(Use the application) as (Use)
User -> (Start)
User --> (Use)
Admin ---> (Use)
note right of Admin : This is an example.
note right of (Use)
A note can also
be on several lines
end note
note "This note is connected\nto several objects." as N2
(Start) .. N2
N2 .. (Use)
@enduml
构造类型
用 << 和 >> 来定义角色或者用例的构造类型。
@startuml
User << Human >>
:Main Database: as MySql << Application >>
(Start) << One Shot >>
(Use the application) as (Use) << Main >>
User -> (Start)
User --> (Use)
MySql --> (Use)
@enduml
第二部分:创建图书管理系统的用例
分析:
角色:图书管理员,借阅者
管理系统:图书信息的查询(存放位置,剩余本书,已借出....),添加,更新,删除,新用户注册办理
借阅系统:图书查询,借阅,归还,已借阅书目,借阅者信息,逾期处理,损坏赔偿
脚本程序:
(1)
@startuml
left to right direction
:图书管理员:
rectangle 管理系统 {
图书管理员 -- (图书信息查询)
图书管理员 -- (添加借出信息)
图书管理员 -- (删除)
图书管理员 -- (更新)
图书管理员 -- (新用户注册办理)
}
@enduml
(2)
@startuml
left to right direction
:图书管理员:
:借阅者:
rectangle 借阅系统 {
:图书管理员: -- (图书查询)
:图书管理员: -- (借阅)
:图书管理员: -- (归还)
:图书管理员: -- (已借阅书目)
:图书管理员: -- (借阅者信息)
:图书管理员: -- (逾期处理)
:图书管理员: -- (损坏赔偿)
(图书查询) -- :借阅者:
(已借阅书目) -- :借阅者:
}
@enduml
用例图:
原文地址:https://www.cnblogs.com/zpp502/p/10580826.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。