Diagram Desk

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

Payment«interface»+pay(amount) bool+cancel() voidCardPayment-cardLast4 String+pay(amount) bool+cancel() voidBankTransfer-bankCode String+pay(amount) bool+cancel() voidOrder+orderNo int+requestPayment() voiduses
Class diagram · 14 shapes

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

ShapeSymbolConnections
PaymentInterfaceholds +pay(amount) bool, +cancel() void · ← CardPayment, BankTransfer, Order
CardPaymentClassholds -cardLast4 String, +pay(amount) bool, +cancel() void · → Payment
BankTransferClassholds -bankCode String, +pay(amount) bool, +cancel() void · → Payment
OrderClassholds +orderNo int, +requestPayment() void · → Payment(uses)

Symbols used here

SymbolMeaning
ClassA box with name, attributes and methods.
InterfaceMarked «interface»; methods only.
RealizationDashed line to the interface, hollow triangle.
DependencyUses another briefly (a parameter); dashed arrow.

All class diagram symbols and how to draw

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

More class diagram examples

All SeewolLabs tools