generated at
Mermaidでクラス図を書く
以下のコード例では省略しているが、1行目に classDiagram と書く必要がある


2022/9/8現在Noteを書く記法がないらしいmrsekut



mermaid
class BankAccount BankAccount : +String owner BankAccount : +Bigdecimal balance BankAccount : +deposit(amount) BankAccount : +withdrawal(amount)
class名
property
method


classの定義方法は2種類
明示的に定義する
mermaid
class Animal
まず関係を書いちゃう
mermaid
Vehicle <|-- Car


property,methodの紐付け方は2種類
出力は同じ
classとpropetyの定義を一緒に書く
記述量が少ない
mermaid
class BankAccount{ +String owner +withdrawal(amount) }
classの定義と、propertyの定義を別の場所にかける
mermaid
class BankAccount BankAccount : +String owner BankAccount : +withdrawal(amount)

型の書き方
返り値の型
mermaid
class BankAccount{ +String owner +withdrawal(amount) int }
generics

Visiblity
+ Public
- Private
# Protected
~ Package/Internal



関係



関係にラベルを付ける
mermaid
classA --|> classB : 継承


双方この関係
-
<|Inheritance
*Composition
oAggregation
>Association
<Association
|>Realization


1
0..1
1..*
*
n
0..n
1..n
mermaid
Customer "1" --> "*" Ticket Student "1" --> "1..*" Course Galaxy --> "many" Star : Contains


enum
mermaid
class Color{ <<enumeration>> RED BLUE GREEN WHITE BLACK }