Payment interface class diagram
Card and bank transfer implement a payment interface that an order uses. Compare the solid inheritance line with the dashed realization line.
The diagram
Reading it step by step
- 'Payment' (interface): 0 attributes, 2 methods.
- 'CardPayment' (class): 1 attributes, 2 methods.
- 'BankTransfer' (class): 1 attributes, 2 methods.
- 'Order' (class): 1 attributes, 1 methods.
- 'CardPayment' implements 'Payment'.
- 'BankTransfer' implements 'Payment'.
- 'Order' depends on 'Payment' (uses).
Shape by shape
| Shape | Symbol | Connections |
|---|---|---|
| Payment | Interface | holds +pay(amount) bool, +cancel() void · ← CardPayment, BankTransfer, Order |
| CardPayment | Class | holds -cardLast4 String, +pay(amount) bool, +cancel() void · → Payment |
| BankTransfer | Class | holds -bankCode String, +pay(amount) bool, +cancel() void · → Payment |
| Order | Class | holds +orderNo int, +requestPayment() void · → Payment(uses) |
Symbols used here
| Symbol | Meaning |
|---|---|
| Class | A box with name, attributes and methods. |
| Interface | Marked «interface»; methods only. |
| Realization | Dashed line to the interface, hollow triangle. |
| Dependency | Uses another briefly (a parameter); dashed arrow. |
Diagram text
Paste this text into the editor to get the same picture, then change the names to fit your own work.
# Payment interface class diagram
classDiagram
class Payment {
<<interface>>
+pay(amount) bool
+cancel() void
}
class CardPayment {
-cardLast4 String
+pay(amount) bool
+cancel() void
}
class BankTransfer {
-bankCode String
+pay(amount) bool
+cancel() void
}
class Order {
+orderNo int
+requestPayment() void
}
Payment <|.. CardPayment
Payment <|.. BankTransfer
Order ..> Payment : uses